All of lore.kernel.org
 help / color / mirror / Atom feed
* [v5,2/5] EDAC, sb_edac: Replace "Socket#" with "SrcID#" in memory controller name
@ 2017-04-26  1:35 Qiuxu Zhuo
  0 siblings, 0 replies; 3+ messages in thread
From: Qiuxu Zhuo @ 2017-04-26  1:35 UTC (permalink / raw)
  To: bp, mchehab; +Cc: arozansk, patrickg, tony.luck, linux-edac, Qiuxu Zhuo

The string "Socket#%d"(where the numer is the memory controller logical
index) in memory controller name is a little confusing for users: E.g,
Broadwell with 4 sockets 2 MCs per socket, it maybe show "Socket#7", but
actually there aren't that many sockets! Change it to "SrcID#%d"(where
the number is read from h/w associated with the socket).

This code is exactly from Tony's previous work from:
https://lkml.kernel.org/r/17395491201298d994a18247ff1561b2e69fb32c.1467412094.git.tony.luck@intel.com

TODO: If we restructure the driver to assign EDAC memory controller per h/w
controller, we can use the one-to-one mapping string "SrcID#%d_Ha#%d" for
a better memory congroller name.

Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
---
 drivers/edac/sb_edac.c | 54 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 35 insertions(+), 19 deletions(-)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 6a5becc..c250021 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -1591,6 +1591,23 @@ static int knl_get_dimm_capacity(struct sbridge_pvt *pvt, u64 *mc_sizes)
 	return 0;
 }
 
+static void get_source_id(struct mem_ctl_info *mci)
+{
+	struct sbridge_pvt *pvt = mci->pvt_info;
+	u32 reg;
+
+	if (pvt->info.type == HASWELL || pvt->info.type == BROADWELL ||
+	    pvt->info.type == KNIGHTS_LANDING)
+		pci_read_config_dword(pvt->pci_sad1, SAD_TARGET, &reg);
+	else
+		pci_read_config_dword(pvt->pci_br0, SAD_TARGET, &reg);
+
+	if (pvt->info.type == KNIGHTS_LANDING)
+		pvt->sbridge_dev->source_id = SOURCE_ID_KNL(reg);
+	else
+		pvt->sbridge_dev->source_id = SOURCE_ID(reg);
+}
+
 static int get_dimm_config(struct mem_ctl_info *mci)
 {
 	struct sbridge_pvt *pvt = mci->pvt_info;
@@ -1608,17 +1625,6 @@ static int get_dimm_config(struct mem_ctl_info *mci)
 		pci_read_config_dword(pvt->pci_ha0, HASWELL_HASYSDEFEATURE2, &reg);
 		pvt->is_chan_hash = GET_BITFIELD(reg, 21, 21);
 	}
-	if (pvt->info.type == HASWELL || pvt->info.type == BROADWELL ||
-			pvt->info.type == KNIGHTS_LANDING)
-		pci_read_config_dword(pvt->pci_sad1, SAD_TARGET, &reg);
-	else
-		pci_read_config_dword(pvt->pci_br0, SAD_TARGET, &reg);
-
-	if (pvt->info.type == KNIGHTS_LANDING)
-		pvt->sbridge_dev->source_id = SOURCE_ID_KNL(reg);
-	else
-		pvt->sbridge_dev->source_id = SOURCE_ID(reg);
-
 	pvt->sbridge_dev->node_id = pvt->info.get_node_id(pvt);
 	edac_dbg(0, "mc#%d: Node ID: %d, source ID: %d\n",
 		 pvt->sbridge_dev->mc,
@@ -3219,12 +3225,14 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
 		pvt->info.max_interleave = ARRAY_SIZE(ibridge_interleave_list);
 		pvt->info.interleave_pkg = ibridge_interleave_pkg;
 		pvt->info.get_width = ibridge_get_width;
-		mci->ctl_name = kasprintf(GFP_KERNEL, "Ivy Bridge Socket#%d", mci->mc_idx);
 
 		/* Store pci devices at mci for faster access */
 		rc = ibridge_mci_bind_devs(mci, sbridge_dev);
 		if (unlikely(rc < 0))
 			goto fail0;
+		get_source_id(mci);
+		mci->ctl_name = kasprintf(GFP_KERNEL, "Ivy Bridge SrcID#%d",
+			pvt->sbridge_dev->source_id);
 		break;
 	case SANDY_BRIDGE:
 		pvt->info.rankcfgr = SB_RANK_CFG_A;
@@ -3242,12 +3250,14 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
 		pvt->info.max_interleave = ARRAY_SIZE(sbridge_interleave_list);
 		pvt->info.interleave_pkg = sbridge_interleave_pkg;
 		pvt->info.get_width = sbridge_get_width;
-		mci->ctl_name = kasprintf(GFP_KERNEL, "Sandy Bridge Socket#%d", mci->mc_idx);
 
 		/* Store pci devices at mci for faster access */
 		rc = sbridge_mci_bind_devs(mci, sbridge_dev);
 		if (unlikely(rc < 0))
 			goto fail0;
+		get_source_id(mci);
+		mci->ctl_name = kasprintf(GFP_KERNEL, "Sandy Bridge SrcID#%d",
+			pvt->sbridge_dev->source_id);
 		break;
 	case HASWELL:
 		/* rankcfgr isn't used */
@@ -3265,12 +3275,14 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
 		pvt->info.max_interleave = ARRAY_SIZE(ibridge_interleave_list);
 		pvt->info.interleave_pkg = ibridge_interleave_pkg;
 		pvt->info.get_width = ibridge_get_width;
-		mci->ctl_name = kasprintf(GFP_KERNEL, "Haswell Socket#%d", mci->mc_idx);
 
 		/* Store pci devices at mci for faster access */
 		rc = haswell_mci_bind_devs(mci, sbridge_dev);
 		if (unlikely(rc < 0))
 			goto fail0;
+		get_source_id(mci);
+		mci->ctl_name = kasprintf(GFP_KERNEL, "Haswell SrcID#%d",
+			pvt->sbridge_dev->source_id);
 		break;
 	case BROADWELL:
 		/* rankcfgr isn't used */
@@ -3288,12 +3300,14 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
 		pvt->info.max_interleave = ARRAY_SIZE(ibridge_interleave_list);
 		pvt->info.interleave_pkg = ibridge_interleave_pkg;
 		pvt->info.get_width = broadwell_get_width;
-		mci->ctl_name = kasprintf(GFP_KERNEL, "Broadwell Socket#%d", mci->mc_idx);
 
 		/* Store pci devices at mci for faster access */
 		rc = broadwell_mci_bind_devs(mci, sbridge_dev);
 		if (unlikely(rc < 0))
 			goto fail0;
+		get_source_id(mci);
+		mci->ctl_name = kasprintf(GFP_KERNEL, "Broadwell SrcID#%d",
+			pvt->sbridge_dev->source_id);
 		break;
 	case KNIGHTS_LANDING:
 		/* pvt->info.rankcfgr == ??? */
@@ -3311,12 +3325,13 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
 		pvt->info.max_interleave = ARRAY_SIZE(knl_interleave_list);
 		pvt->info.interleave_pkg = ibridge_interleave_pkg;
 		pvt->info.get_width = knl_get_width;
-		mci->ctl_name = kasprintf(GFP_KERNEL,
-			"Knights Landing Socket#%d", mci->mc_idx);
 
 		rc = knl_mci_bind_devs(mci, sbridge_dev);
 		if (unlikely(rc < 0))
 			goto fail0;
+		get_source_id(mci);
+		mci->ctl_name = kasprintf(GFP_KERNEL, "Knights Landing SrcID#%d",
+			pvt->sbridge_dev->source_id);
 		break;
 	}
 
@@ -3331,13 +3346,14 @@ static int sbridge_register_mci(struct sbridge_dev *sbridge_dev, enum type type)
 	if (unlikely(edac_mc_add_mc(mci))) {
 		edac_dbg(0, "MC: failed edac_mc_add_mc()\n");
 		rc = -EINVAL;
-		goto fail0;
+		goto fail;
 	}
 
 	return 0;
 
-fail0:
+fail:
 	kfree(mci->ctl_name);
+fail0:
 	edac_mc_free(mci);
 	sbridge_dev->mci = NULL;
 	return rc;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [v5,2/5] EDAC, sb_edac: Replace "Socket#" with "SrcID#" in memory controller name
@ 2017-05-07 14:33 Qiuxu Zhuo
  0 siblings, 0 replies; 3+ messages in thread
From: Qiuxu Zhuo @ 2017-05-07 14:33 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: mchehab, arozansk, patrickg, Luck, Tony, linux-edac

> From: Borislav Petkov [mailto:bp@alien8.de] 
> So then take Tony's patch with the Reported-by tags in there and its commit message. Why are you redoing it?

Hi Boris,

OK, I'll take Tony's original patch with the Reported-by tags and its commit message in next version.
Thanks for correcting me. 

BR
qiuxu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [v5,2/5] EDAC, sb_edac: Replace "Socket#" with "SrcID#" in memory controller name
@ 2017-05-05 16:43 Borislav Petkov
  0 siblings, 0 replies; 3+ messages in thread
From: Borislav Petkov @ 2017-05-05 16:43 UTC (permalink / raw)
  To: Qiuxu Zhuo; +Cc: mchehab, arozansk, patrickg, tony.luck, linux-edac

On Wed, Apr 26, 2017 at 09:35:19AM +0800, Qiuxu Zhuo wrote:
> The string "Socket#%d"(where the numer is the memory controller logical
> index) in memory controller name is a little confusing for users: E.g,
> Broadwell with 4 sockets 2 MCs per socket, it maybe show "Socket#7", but
> actually there aren't that many sockets! Change it to "SrcID#%d"(where
> the number is read from h/w associated with the socket).
> 
> This code is exactly from Tony's previous work from:
> https://lkml.kernel.org/r/17395491201298d994a18247ff1561b2e69fb32c.1467412094.git.tony.luck@intel.com

So then take Tony's patch with the Reported-by tags in there and its
commit message. Why are you redoing it?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-07 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26  1:35 [v5,2/5] EDAC, sb_edac: Replace "Socket#" with "SrcID#" in memory controller name Qiuxu Zhuo
2017-05-05 16:43 Borislav Petkov
2017-05-07 14:33 Qiuxu Zhuo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.