Re: [PATCH] ddr_dimms: Check spd->mem_type before computing parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux