mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
Cc: dougthompson@xmission.com, m.chehab@samsung.com,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] edac, amd64_edac: Modify usage of amd64_read_dct_pci_cfg()
Date: Mon, 25 Aug 2014 07:43:39 +0200	[thread overview]
Message-ID: <20140825054339.GA13911@nazgul.tnic> (raw)
In-Reply-To: <1408659586-4736-1-git-send-email-aravind.gopalakrishnan@amd.com>

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.
--

  reply	other threads:[~2014-08-25  5:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21 22:19 Aravind Gopalakrishnan
2014-08-25  5:43 ` Borislav Petkov [this message]
2014-08-25  7:49   ` Borislav Petkov
2014-08-26 17:35   ` Aravind Gopalakrishnan

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=20140825054339.GA13911@nazgul.tnic \
    --to=bp@alien8.de \
    --cc=aravind.gopalakrishnan@amd.com \
    --cc=dougthompson@xmission.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.chehab@samsung.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®