mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: wan wei <onewayforever@gmail.com>
To: Borislav Petkov <borislav.petkov@amd.com>, dougthompson@xmission.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] amd64_edac: Rewrite unganged mode code of  f10_early_channel_count
Date: Fri, 7 Aug 2009 13:36:30 +0800	[thread overview]
Message-ID: <86bb1aef0908062236w1912a909yfa892d40f1776e08@mail.gmail.com> (raw)

Hi,
     I rechecked the f10_early_channel_count function, and found more
bugs in unganged mode. This patch will fix  bugs under following
conditions,
    a. only one DIMM in each channelof the node,
    b. two DIMMs are populated in the same channel of the node,
    c. there is no DIMM in a node(other than node 0),
    a and b  mean both dbam should be checked in any condition,  and c
means even channels==0 is ok.

the patch has been tested and works well in  this  4 ways machine:
   node 0:  2 DIMMS on each channel
   node11: no DIMMS
   node2:  2 DIMM on the chanel 0
   node3:  one DIMM on each channel

thanks :-)

Signed-off-by: Wan Wei<wanwei@mail.dawning.com.cn>

---
 drivers/edac/amd64_edac.c |   46 ++++++++++++++------------------------------
 1 files changed, 15 insertions(+), 31 deletions(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index e2a10bc..7a328fa 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1200,6 +1200,7 @@ static int f10_early_channel_count(struct amd64_pvt *pvt)
 {
 	int err = 0, channels = 0;
 	u32 dbam;
+	int i;

 	err = pci_read_config_dword(pvt->dram_f2_ctl, F10_DCLR_0, &pvt->dclr0);
 	if (err)
@@ -1236,40 +1237,23 @@ static int f10_early_channel_count(struct
amd64_pvt *pvt)
 	if (err)
 		goto err_reg;

-	if (DBAM_DIMM(0, dbam) > 0)
-		channels++;
-	if (DBAM_DIMM(1, dbam) > 0)
-		channels++;
-	if (DBAM_DIMM(2, dbam) > 0)
-		channels++;
-	if (DBAM_DIMM(3, dbam) > 0)
-		channels++;
-
-	/* If more than 2 DIMMs are present, then we have 2 channels */
-	if (channels > 2)
-		channels = 2;
-	else if (channels == 0) {
-		/* No DIMMs on DCT0, so look at DCT1 */
-		err = pci_read_config_dword(pvt->dram_f2_ctl, DBAM1, &dbam);
-		if (err)
-			goto err_reg;
-
-		if (DBAM_DIMM(0, dbam) > 0)
+	for (i = 0; i < 4; i++) {
+		if (DBAM_DIMM(i, dbam) > 0) {
 			channels++;
-		if (DBAM_DIMM(1, dbam) > 0)
-			channels++;
-		if (DBAM_DIMM(2, dbam) > 0)
-			channels++;
-		if (DBAM_DIMM(3, dbam) > 0)
-			channels++;
-
-		if (channels > 2)
-			channels = 2;
+			break;
+		}
 	}

-	/* If we found ALL 0 values, then assume just ONE DIMM-ONE Channel */
-	if (channels == 0)
-		channels = 1;
+	err = pci_read_config_dword(pvt->dram_f2_ctl, DBAM1, &dbam);
+	if (err)
+		goto err_reg;
+
+	for (i = 0; i < 4; i++) {
+		if (DBAM_DIMM(i, dbam) > 0) {
+			channels++;
+			break;
+		}
+	}

 	debugf0("MCT channel count: %d\n", channels);

-- 
1.4.4.2

             reply	other threads:[~2009-08-07  5:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-07  5:36 wan wei [this message]
2009-08-07 12:29 ` Borislav Petkov
2009-08-07 14:39   ` wan wei
2009-08-07 15:11     ` Borislav Petkov

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=86bb1aef0908062236w1912a909yfa892d40f1776e08@mail.gmail.com \
    --to=onewayforever@gmail.com \
    --cc=borislav.petkov@amd.com \
    --cc=dougthompson@xmission.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®