mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: John Watts <contact@jookia.org>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] ddr_dimms: Check spd->mem_type before computing parameters
Date: Thu, 2 Feb 2023 08:23:03 +0100	[thread overview]
Message-ID: <20230202072303.GJ13319@pengutronix.de> (raw)
In-Reply-To: <20230201053334.971854-1-contact@jookia.org>

On Wed, Feb 01, 2023 at 04:33:34PM +1100, John Watts wrote:
> Checking the mem_type here as well as the CRC means developers can
> just read the SPD and pass it directly to parameter computation.
> 
> This makes it so developers can rely fully on parameters for checking
> if RAM is compatible with their board and not need to worry about reading
> SPD data themselves.
> 
> Signed-off-by: John Watts <contact@jookia.org>
> ---
>  common/ddr1_dimm_params.c | 5 +++++
>  common/ddr2_dimm_params.c | 7 +++++++
>  common/ddr3_dimm_params.c | 5 +++++
>  common/ddr4_dimm_params.c | 5 +++++
>  4 files changed, 22 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/common/ddr1_dimm_params.c b/common/ddr1_dimm_params.c
> index 3f8759c351..77e047a051 100644
> --- a/common/ddr1_dimm_params.c
> +++ b/common/ddr1_dimm_params.c
> @@ -221,6 +221,11 @@ unsigned int ddr1_compute_dimm_parameters(unsigned int mclk_ps,
>  {
>  	int ret;
>  
> +	if (spd->mem_type != SPD_MEMTYPE_DDR) {
> +		printf("DIMM: SPD data is not DDR1\n");
> +		return 3;
> +	}
> +
>  	ret = ddr1_spd_check(spd);
>  	if (ret) {
>  		printf("DIMM: failed checksum\n");
> diff --git a/common/ddr2_dimm_params.c b/common/ddr2_dimm_params.c
> index 2cec662ecb..b9c0922385 100644
> --- a/common/ddr2_dimm_params.c
> +++ b/common/ddr2_dimm_params.c
> @@ -206,6 +206,13 @@ unsigned int ddr2_compute_dimm_parameters(unsigned int mclk_ps,
>  {
>  	int ret;
>  
> +	if (spd->mem_type != SPD_MEMTYPE_DDR2 &&
> +	    spd->mem_type != SPD_MEMTYPE_DDR2_FBDIMM &&
> +	    spd->mem_type != SPD_MEMTYPE_DDR2_FBDIMM_PROBE) {
> +		printf("DIMM: SPD data is not DDR2\n");
> +		return 3;
> +	}
> +
>  	ret = ddr2_spd_check(spd);
>  	if (ret) {
>  		printf("DIMM: failed checksum\n");
> diff --git a/common/ddr3_dimm_params.c b/common/ddr3_dimm_params.c
> index 6c3dbc6877..1b7512a275 100644
> --- a/common/ddr3_dimm_params.c
> +++ b/common/ddr3_dimm_params.c
> @@ -86,6 +86,11 @@ unsigned int ddr3_compute_dimm_parameters(const struct ddr3_spd_eeprom *spd,
>  	int ftb_10th_ps;
>  	int i;
>  
> +	if (spd->mem_type != SPD_MEMTYPE_DDR3) {
> +		printf("DIMM: SPD data is not DDR3\n");
> +		return 3;
> +	}
> +
>  	ret = ddr3_spd_check(spd);
>  	if (ret) {
>  		printf("DIMM: failed checksum\n");
> diff --git a/common/ddr4_dimm_params.c b/common/ddr4_dimm_params.c
> index 9fa3225d90..045cbd457c 100644
> --- a/common/ddr4_dimm_params.c
> +++ b/common/ddr4_dimm_params.c
> @@ -136,6 +136,11 @@ unsigned int ddr4_compute_dimm_parameters(const struct ddr4_spd_eeprom *spd,
>  	u8 *ptr;
>  	u8 val;
>  
> +	if (spd->mem_type != SPD_MEMTYPE_DDR4) {
> +		printf("DIMM: SPD data is not DDR4\n");
> +		return 3;
> +	}
> +
>  	ret = ddr4_spd_check(spd);
>  	if (ret) {
>  		printf("DIMM: failed checksum\n");
> -- 
> 2.39.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2023-02-02  7:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01  5:33 John Watts
2023-02-02  7:23 ` Sascha Hauer [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=20230202072303.GJ13319@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=contact@jookia.org \
    /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