|
|
99c779 |
From f9d40b3393553fe7fd0230033604fcf38a9053f4 Mon Sep 17 00:00:00 2001
|
|
|
99c779 |
From: Dan Callaghan <dcallagh@redhat.com>
|
|
|
99c779 |
Date: Mon, 13 Jul 2015 16:54:27 +1000
|
|
|
99c779 |
Subject: [PATCH 19/26] devicetree: identify DIMMs from IBM memory-controller
|
|
|
99c779 |
nodes (#695)
|
|
|
99c779 |
|
|
|
99c779 |
Older IBM POWER systems (for example JS20) have a /memory-controller@*
|
|
|
99c779 |
node in their device tree, which exposes DIMM info under IBM-specific
|
|
|
99c779 |
properties.
|
|
|
99c779 |
---
|
|
|
99c779 |
src/core/device-tree.cc | 52 ++++++++++++++++++++++++++++++++++++++++++-------
|
|
|
99c779 |
1 file changed, 45 insertions(+), 7 deletions(-)
|
|
|
99c779 |
|
|
|
99c779 |
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
|
|
|
99c779 |
index 5f81dc4..de8446e 100644
|
|
|
99c779 |
--- a/src/core/device-tree.cc
|
|
|
99c779 |
+++ b/src/core/device-tree.cc
|
|
|
99c779 |
@@ -981,8 +981,9 @@ static void scan_devtree_cpu(hwNode & core)
|
|
|
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 |
+ pushd(path + "/" + name);
|
|
|
99c779 |
+ if(name.substr(0, 7) == "ms-dimm" ||
|
|
|
99c779 |
+ name.substr(0, 18) == "IBM,memory-module@")
|
|
|
99c779 |
{
|
|
|
99c779 |
hwNode bank("bank", hw::memory);
|
|
|
99c779 |
bank.claim(true);
|
|
|
99c779 |
@@ -999,12 +1000,24 @@ static void add_memory_bank(string name, string path, hwNode & core)
|
|
|
99c779 |
if(product != "")
|
|
|
99c779 |
bank.setProduct(hw::strip(product));
|
|
|
99c779 |
|
|
|
99c779 |
+ string description = "DIMM";
|
|
|
99c779 |
+ string package = hw::strip(get_string("ibm,mem-package"));
|
|
|
99c779 |
+ if (!package.empty())
|
|
|
99c779 |
+ description = package;
|
|
|
99c779 |
+ string memtype = hw::strip(get_string("ibm,mem-type"));
|
|
|
99c779 |
+ if (!memtype.empty())
|
|
|
99c779 |
+ description += " " + memtype;
|
|
|
99c779 |
if(exists("description"))
|
|
|
99c779 |
- bank.setDescription(hw::strip(get_string("description")));
|
|
|
99c779 |
+ description = hw::strip(get_string("description"));
|
|
|
99c779 |
+ bank.setDescription(description);
|
|
|
99c779 |
+
|
|
|
99c779 |
if(exists("ibm,loc-code"))
|
|
|
99c779 |
bank.setSlot(hw::strip(get_string("ibm,loc-code")));
|
|
|
99c779 |
- if(unsigned long size = get_number("size"))
|
|
|
99c779 |
- bank.setSize(size*1024*1024);
|
|
|
99c779 |
+ unsigned long size = get_number("size") * 1024 * 1024;
|
|
|
99c779 |
+ if (exists("ibm,size"))
|
|
|
99c779 |
+ size = get_u32("ibm,size");
|
|
|
99c779 |
+ if (size > 0)
|
|
|
99c779 |
+ bank.setSize(size);
|
|
|
99c779 |
|
|
|
99c779 |
memory->addChild(bank);
|
|
|
99c779 |
} else if(name.substr(0, 4) == "dimm") {
|
|
|
99c779 |
@@ -1026,7 +1039,7 @@ void add_memory_bank(string name, string path, hwNode & core)
|
|
|
99c779 |
|
|
|
99c779 |
for (int i = 0; i < n; i++)
|
|
|
99c779 |
{
|
|
|
99c779 |
- add_memory_bank(dirlist[i]->d_name, path + name + "/", core);
|
|
|
99c779 |
+ add_memory_bank(dirlist[i]->d_name, path + "/" + name, core);
|
|
|
99c779 |
free(dirlist[i]);
|
|
|
99c779 |
}
|
|
|
99c779 |
free(dirlist);
|
|
|
99c779 |
@@ -1056,6 +1069,30 @@ static void scan_devtree_memory_powernv(hwNode & core)
|
|
|
99c779 |
}
|
|
|
99c779 |
|
|
|
99c779 |
|
|
|
99c779 |
+// older POWER hardware
|
|
|
99c779 |
+static void scan_devtree_memory_ibm(hwNode & core)
|
|
|
99c779 |
+{
|
|
|
99c779 |
+ struct dirent **namelist;
|
|
|
99c779 |
+ pushd(DEVICETREE);
|
|
|
99c779 |
+ int n = scandir(".", &namelist, selectdir, alphasort);
|
|
|
99c779 |
+ popd();
|
|
|
99c779 |
+
|
|
|
99c779 |
+ if (n < 0)
|
|
|
99c779 |
+ return;
|
|
|
99c779 |
+
|
|
|
99c779 |
+ for (int i = 0; i < n; i++)
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ if (strncmp(namelist[i]->d_name, "memory-controller@", 18) == 0)
|
|
|
99c779 |
+ {
|
|
|
99c779 |
+ add_memory_bank(namelist[i]->d_name, DEVICETREE, core);
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+ free(namelist[i]);
|
|
|
99c779 |
+ }
|
|
|
99c779 |
+ free(namelist);
|
|
|
99c779 |
+}
|
|
|
99c779 |
+
|
|
|
99c779 |
+
|
|
|
99c779 |
+// Apple and ARM
|
|
|
99c779 |
static void scan_devtree_memory(hwNode & core)
|
|
|
99c779 |
{
|
|
|
99c779 |
int currentmc = -1; // current memory controller
|
|
|
99c779 |
@@ -1338,6 +1375,7 @@ bool scan_device_tree(hwNode & n)
|
|
|
99c779 |
core->addHint("icon", string("board"));
|
|
|
99c779 |
scan_devtree_root(*core);
|
|
|
99c779 |
scan_devtree_cpu_power(*core);
|
|
|
99c779 |
+ scan_devtree_memory_ibm(*core);
|
|
|
99c779 |
scan_devtree_memory_powernv(*core);
|
|
|
99c779 |
scan_devtree_firmware_powernv(*core);
|
|
|
99c779 |
n.addCapability("powernv", "Non-virtualized");
|
|
|
99c779 |
--
|
|
|
99c779 |
2.10.2
|
|
|
99c779 |
|