dimm: use size to determine if DIMM is present and functional
Currently, we are using "NO DIMM" in dimmManufacturer to determine if
there is a DIMM sensor or not. However, it's "Unknown" in an AMD machine
we are testing.
Looking into SMBIOS spec (DSP0134_3.3.0), it looks like using size to
determine if DIMM is present and functional is a better option.
Tested:
Check an Intel CPU machine and the Present is true when DIMM is there
and false when it's not:
```
busctl introspect xyz.openbmc_project.Smbios.MDR_V2 \
/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 \
xyz.openbmc_project.Inventory.Item
NAME TYPE SIGNATURE RESULT/VALUE
FLAGS
.Present property b true
emits-change writable
.PrettyName property s ""
emits-change writable
busctl introspect xyz.openbmc_project.Smbios.MDR_V2 \
/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm1 \
xyz.openbmc_project.Inventory.Item
NAME TYPE SIGNATURE RESULT/VALUE
FLAGS
.Present property b false
emits-change writable
.PrettyName property s ""
emits-change writable
```
Check an AMD machine and it works fine with a bad DIMM and a good DIMM:
```
busctl introspect
xyz.openbmc_project.Smbios.MDR_V2
/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0
xyz.openbmc_project.Inventory.Item
NAME TYPE SIGNATURE RESULT/VALUE
FLAGS
.Present property b false
emits-change writable
.PrettyName property s ""
emits-change writable
busctl introspect
xyz.openbmc_project.Smbios.MDR_V2
/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm1
xyz.openbmc_project.Inventory.Item
NAME TYPE SIGNATURE RESULT/VALUE
FLAGS
.Present property b true
emits-change writable
.PrettyName property s ""
emits-change writable
```
Change-Id: If6ea55f35b4af3225c4a07de481d930fa461b3e7
Signed-off-by: Tom Tung <shes050117@gmail.com>
diff --git a/src/dimm.cpp b/src/dimm.cpp
index 9cc7ef3..8690969 100644
--- a/src/dimm.cpp
+++ b/src/dimm.cpp
@@ -75,6 +75,10 @@
{
dimmSize(memoryInfo->size);
}
+ // If the size is 0, no memory device is installed in the socket.
+ const auto isDimmPresent = memoryInfo->size > 0;
+ present(isDimmPresent);
+ functional(isDimmPresent);
dimmDeviceLocator(memoryInfo->bankLocator, memoryInfo->deviceLocator,
memoryInfo->length, dataIn);
@@ -252,19 +256,14 @@
{
std::string result = positionToString(positionNum, structLen, dataIn);
- bool val = true;
if (result == "NO DIMM")
{
- val = false;
-
// No dimm presence so making manufacturer value as "" (instead of
// NO DIMM - as there won't be any manufacturer for DIMM which is not
// present).
result = "";
}
manufacturer(result);
- present(val);
- functional(val);
}
std::string Dimm::manufacturer(std::string value)