|
|
99c779 |
From f1cd42c0c6f434e15ba322970cfa4519ee1f523d Mon Sep 17 00:00:00 2001
|
|
|
99c779 |
From: Jack Miller <jack@codezen.org>
|
|
|
99c779 |
Date: Tue, 16 Aug 2016 15:08:51 -0500
|
|
|
99c779 |
Subject: [PATCH 38/43] devtree: Report memory info for BMC based Power System
|
|
|
99c779 |
|
|
|
99c779 |
Some variants of Power System (BMC service processor system) device tree
|
|
|
99c779 |
contains SPD information. Also it has memory-buffer representation in
|
|
|
99c779 |
device tree.
|
|
|
99c779 |
|
|
|
99c779 |
This patch adds support to display memory information on this system.
|
|
|
99c779 |
|
|
|
99c779 |
Sample output;
|
|
|
99c779 |
*-bank:1
|
|
|
99c779 |
description: RDIMM DDR3 1600 MHz (0.6ns)
|
|
|
99c779 |
product: HMT42GR7BFR4A-PB
|
|
|
99c779 |
vendor: Hynix Semiconductor (Hyundai Electronics)
|
|
|
99c779 |
physical id: 1
|
|
|
99c779 |
version: 5438,15 33,01
|
|
|
99c779 |
serial: 0x10c0af2c
|
|
|
99c779 |
slot: Physical:/Sys0/Node0/DIMM11
|
|
|
99c779 |
size: 16GiB
|
|
|
99c779 |
clock: 1333MHz (0.8ns)
|
|
|
99c779 |
capabilities: ecc spd-1.3
|
|
|
99c779 |
configuration: errordetection=ecc
|
|
|
99c779 |
|
|
|
99c779 |
Signed-off-by: Jack Miller <jack@codezen.org>
|
|
|
99c779 |
[Updated description, fixed minor issues - Vasant]
|
|
|
99c779 |
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
|
|
|
99c779 |
---
|
|
|
99c779 |
src/core/device-tree.cc | 71 +++++++++++++++++++++++++++++++++++++++++++++----
|
|
|
99c779 |
1 file changed, 66 insertions(+), 5 deletions(-)
|
|
|
99c779 |
|
|
|
99c779 |
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
|
|
|
99c779 |
index 41034e5..b7d0d57 100644
|
|
|
99c779 |
--- a/src/core/device-tree.cc
|
|
|
99c779 |
+++ b/src/core/device-tree.cc
|
|
|
99c779 |
@@ -753,6 +753,57 @@ static void scan_devtree_cpu_power(hwNode & core)
|
|
|
99c779 |
delete it->second;
|
|
|
99c779 |
}
|
|
|
99c779 |
|
|
|
99c779 |
+static bool add_memory_bank_mba_dimm(string path,
|
|
|
99c779 |
+ unsigned long serial, hwNode & bank)
|
|
|
99c779 |
+{
|
|
|
99c779 |
+ bool found = false;
|
|
|
99c779 |
+ int n;
|
|
|
99c779 |
+ struct dirent **namelist;
|
|
|
99c779 |
+
|
|
|
99c779 |
+ pushd(path);
|
|
|
99c779 |
+ n = scandir(".", &namelist, selectdir, alphasort);
|
|
|
99c779 |
+ popd();
|
|
|
99c779 |
+
|
|
|
99c779 |
+ if (n < 0)
|
|
|
99c779 |
+ return found;
|
|
|
99c779 |
+
|
|
|
99c779 |
+ for (int i = 0; i < n; i++)
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ string sname = string(namelist[i]->d_name);
|
|
|
99c779 |
+ string fullpath = path + "/" + sname;
|
|
|
99c779 |
+
|
|
|
99c779 |
+ if (found)
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ free(namelist[i]);
|
|
|
99c779 |
+ continue;
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+
|
|
|
99c779 |
+ if (sname.substr(0, 13) == "memory-buffer")
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ if (exists(fullpath + "/frequency-mhz"))
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ int hz = get_u32(fullpath + "/frequency-mhz") * 1000000;
|
|
|
99c779 |
+ bank.setClock(hz);
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+ found = add_memory_bank_mba_dimm(fullpath, serial, bank);
|
|
|
99c779 |
+ } else if (sname.substr(0, 3) == "mba") {
|
|
|
99c779 |
+ found = add_memory_bank_mba_dimm(fullpath, serial, bank);
|
|
|
99c779 |
+ } else if ((sname.substr(0, 4) == "dimm") &&
|
|
|
99c779 |
+ (get_u32(fullpath + "/serial-number") == serial)) {
|
|
|
99c779 |
+ vector < reg_entry > regs = get_reg_property(fullpath);
|
|
|
99c779 |
+ bank.setSize(regs[0].size);
|
|
|
99c779 |
+
|
|
|
99c779 |
+ bank.setSlot(hw::strip(get_string(fullpath + "/ibm,slot-location-code")));
|
|
|
99c779 |
+ found = true;
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+ free(namelist[i]);
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+
|
|
|
99c779 |
+ free(namelist);
|
|
|
99c779 |
+ return found;
|
|
|
99c779 |
+}
|
|
|
99c779 |
+
|
|
|
99c779 |
+
|
|
|
99c779 |
static void add_memory_bank_spd(string path, hwNode & bank)
|
|
|
99c779 |
{
|
|
|
99c779 |
char dimmversion[20];
|
|
|
99c779 |
@@ -885,6 +936,8 @@ static void add_memory_bank_spd(string path, hwNode & bank)
|
|
|
99c779 |
snprintf(buff, sizeof(buff), "0x%lx", serial);
|
|
|
99c779 |
bank.setSerial(buff);
|
|
|
99c779 |
|
|
|
99c779 |
+ add_memory_bank_mba_dimm(DEVICETREE, serial, bank);
|
|
|
99c779 |
+
|
|
|
99c779 |
snprintf(buff, sizeof(buff), "spd-%d.%d", (version & 0xF0) >> 4, version & 0x0F);
|
|
|
99c779 |
bank.addCapability(buff);
|
|
|
99c779 |
}
|
|
|
99c779 |
@@ -895,18 +948,17 @@ static void add_memory_bank(string name, string path, hwNode & core)
|
|
|
99c779 |
string product;
|
|
|
99c779 |
int n;
|
|
|
99c779 |
|
|
|
99c779 |
+ hwNode *memory = core.getChild("memory");
|
|
|
99c779 |
+ if(!memory)
|
|
|
99c779 |
+ memory = core.addChild(hwNode("memory", hw::memory));
|
|
|
99c779 |
+
|
|
|
99c779 |
pushd(path + name);
|
|
|
99c779 |
if(name.substr(0, 7) == "ms-dimm")
|
|
|
99c779 |
{
|
|
|
99c779 |
- hwNode *memory = core.getChild("memory");
|
|
|
99c779 |
-
|
|
|
99c779 |
hwNode bank("bank", hw::memory);
|
|
|
99c779 |
bank.claim(true);
|
|
|
99c779 |
bank.addHint("icon", string("memory"));
|
|
|
99c779 |
|
|
|
99c779 |
- if(!memory)
|
|
|
99c779 |
- memory = core.addChild(hwNode("memory", hw::memory));
|
|
|
99c779 |
-
|
|
|
99c779 |
if(exists("serial-number"))
|
|
|
99c779 |
bank.setSerial(hw::strip(get_string("serial-number")));
|
|
|
99c779 |
|
|
|
99c779 |
@@ -926,6 +978,15 @@ static void add_memory_bank(string name, string path, hwNode & core)
|
|
|
99c779 |
bank.setSize(size*1024*1024);
|
|
|
99c779 |
|
|
|
99c779 |
memory->addChild(bank);
|
|
|
99c779 |
+ } else if(name.substr(0, 4) == "dimm") {
|
|
|
99c779 |
+ hwNode bank("bank", hw::memory);
|
|
|
99c779 |
+ bank.claim(true);
|
|
|
99c779 |
+ bank.addHint("icon", string("memory"));
|
|
|
99c779 |
+
|
|
|
99c779 |
+ // Parse Memory SPD data
|
|
|
99c779 |
+ add_memory_bank_spd(path + name + "/spd", bank);
|
|
|
99c779 |
+
|
|
|
99c779 |
+ memory->addChild(bank);
|
|
|
99c779 |
}
|
|
|
99c779 |
|
|
|
99c779 |
n = scandir(".", &dirlist, selectdir, alphasort);
|
|
|
99c779 |
--
|
|
|
99c779 |
2.10.2
|
|
|
99c779 |
|