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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 25 Aug 2014 07:43:39 +0200
From:	Borislav Petkov <bp@...en8.de>
To:	Aravind Gopalakrishnan <aravind.gopalakrishnan@....com>
Cc:	dougthompson@...ssion.com, m.chehab@...sung.com,
	linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] edac, amd64_edac: Modify usage of
 amd64_read_dct_pci_cfg()

On Thu, Aug 21, 2014 at 05:19:46PM -0500, Aravind Gopalakrishnan wrote:
> @@ -767,17 +750,25 @@ static void read_dct_base_mask(struct amd64_pvt *pvt)
>  		int reg1   = DCSB1 + (cs * 4);
>  		u32 *base0 = &pvt->csels[0].csbases[cs];
>  		u32 *base1 = &pvt->csels[1].csbases[cs];
> +		u8 dct = 0;
>  
> -		if (!amd64_read_dct_pci_cfg(pvt, reg0, base0))
> +		if (!amd64_read_dct_pci_cfg(pvt, dct, reg0, base0))
>  			edac_dbg(0, "  DCSB0[%d]=0x%08x reg: F2x%x\n",
>  				 cs, *base0, reg0);
>  
> -		if (pvt->fam == 0xf || dct_ganging_enabled(pvt))
> +		if (pvt->fam == 0xf) {
>  			continue;
> -
> -		if (!amd64_read_dct_pci_cfg(pvt, reg1, base1))
> -			edac_dbg(0, "  DCSB1[%d]=0x%08x reg: F2x%x\n",
> -				 cs, *base1, reg1);
> +		} else if (pvt->fam == 0x10 && !dct_ganging_enabled(pvt)) {
> +			if (!amd64_read_pci_cfg(pvt->F2, reg1, base1))
> +				edac_dbg(0, "  DCSB1[%d]=0x%08x reg: F2x%x\n",
> +					 cs, *base1, reg1);
> +		} else {
> +			dct = ((pvt->fam == 0x15)
> +				&& (pvt->model == 0x30)) ? 3 : 1;
> +			if (!amd64_read_dct_pci_cfg(pvt, dct, reg0, base1))
> +				edac_dbg(0, "  DCSB1[%d]=0x%08x reg: F2x%x\n",
> +					 cs, *base1, reg0);
> +		}
>  	}
>  
>  	for_each_chip_select_mask(cs, 0, pvt) {
> @@ -785,17 +776,25 @@ static void read_dct_base_mask(struct amd64_pvt *pvt)
>  		int reg1   = DCSM1 + (cs * 4);
>  		u32 *mask0 = &pvt->csels[0].csmasks[cs];
>  		u32 *mask1 = &pvt->csels[1].csmasks[cs];
> +		u8 dct = 0;
>  
> -		if (!amd64_read_dct_pci_cfg(pvt, reg0, mask0))
> +		if (!amd64_read_dct_pci_cfg(pvt, dct, reg0, mask0))
>  			edac_dbg(0, "    DCSM0[%d]=0x%08x reg: F2x%x\n",
>  				 cs, *mask0, reg0);
>  
> -		if (pvt->fam == 0xf || dct_ganging_enabled(pvt))
> +		if (pvt->fam == 0xf) {
>  			continue;
> -
> -		if (!amd64_read_dct_pci_cfg(pvt, reg1, mask1))
> -			edac_dbg(0, "    DCSM1[%d]=0x%08x reg: F2x%x\n",
> -				 cs, *mask1, reg1);
> +		} else if (pvt->fam == 0x10 && !dct_ganging_enabled(pvt)) {
> +			if (!amd64_read_pci_cfg(pvt->F2, reg1, mask1))
> +				edac_dbg(0, "    DCSM1[%d]=0x%08x reg: F2x%x\n",
> +					 cs, *mask1, reg1);
> +		} else {
> +			dct = ((pvt->fam == 0x15)
> +				&& (pvt->model == 0x30)) ? 3 : 1;
> +			if (!amd64_read_dct_pci_cfg(pvt, dct, reg0, mask1))
> +				edac_dbg(0, "    DCSM1[%d]=0x%08x reg: F2x%x\n",
> +					 cs, *mask1, reg0);
> +		}

This is almost unreadable now with all the family checks everywhere.
You need to hide all that per-family logic into the function and have a
single

amd_read_pci_cfg_dct(pvt, dct, ...)

which contains all that logic. Calling code doesn't need to care about
details like on which family it is running, etc, etc.

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists