[Skiboot] [PATCH] hdata: Fix DIMM size property

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Fri Apr 13 00:22:19 AEST 2018


Today we parse vpd blob to get DIMM size information. This is limited
to FSP based system. HDAT provides DIMM size value. Lets use that to
populate device tree. So that we can get size information on BMC based
system as well.

Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
CC: Oliver O'Halloran <oohall at gmail.com>
---
 hdata/memory.c               | 41 +++++++++++------------------------------
 hdata/test/p8-840-spira.dts  |  4 ++--
 hdata/test/p81-811.spira.dts |  8 ++++----
 3 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/hdata/memory.c b/hdata/memory.c
index a636e8181..e6fd351e5 100644
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -236,32 +236,19 @@ static void add_bus_freq_to_ram_area(struct dt_node *ram_node, u32 chip_id)
 }
 
 static void add_size_to_ram_area(struct dt_node *ram_node,
-				 const struct HDIF_common_hdr *hdr,
-				 int indx_vpd)
+				 const struct HDIF_common_hdr *ramarea)
 {
-	const void	*fruvpd;
-	unsigned int	fruvpd_sz;
-	const void	*kw;
-	char		*str;
-	uint8_t		kwsz;
-
-	fruvpd = HDIF_get_idata(hdr, indx_vpd, &fruvpd_sz);
-	if (!CHECK_SPPTR(fruvpd))
-		return;
+	char	str[16];
+	const struct HDIF_ram_area_size *ram_area_sz;
 
-	/* DIMM Size */
-	kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "SZ", &kwsz);
-	if (!kw)
+	/* DIMM size */
+	ram_area_sz = HDIF_get_idata(ramarea, 3, NULL);
+	if (!CHECK_SPPTR(ram_area_sz))
 		return;
 
-	str = zalloc(kwsz + 1);
-	if (!str){
-		prerror("Allocation failed\n");
-		return;
-	}
-	memcpy(str, kw, kwsz);
+	memset(str, 0, 16);
+	snprintf(str, 16, "%d", be32_to_cpu(ram_area_sz->mb));
 	dt_add_property_string(ram_node, "size", str);
-	free(str);
 }
 
 static void vpd_add_ram_area(const struct HDIF_common_hdr *msarea)
@@ -308,21 +295,15 @@ static void vpd_add_ram_area(const struct HDIF_common_hdr *msarea)
 
 		vpd_blob = HDIF_get_idata(ramarea, 1, &ram_sz);
 
+		/* DIMM size */
+		add_size_to_ram_area(ram_node, ramarea);
 		/*
 		 * For direct-attached memory we have a DDR "Serial
 		 * Presence Detection" blob rather than an IBM keyword
 		 * blob.
 		 */
-		if (vpd_valid(vpd_blob, ram_sz)) {
-			/* the ibm,vpd blob was added in dt_add_vpd_node() */
-			add_size_to_ram_area(ram_node, ramarea, 1);
-		} else {
-			/*
-			 * FIXME: There's probably a way to calculate the
-			 * size of the DIMM from the SPD info.
-			 */
+		if (!vpd_valid(vpd_blob, ram_sz))
 			dt_add_property(ram_node, "spd", vpd_blob, ram_sz);
-		}
 	}
 }
 
diff --git a/hdata/test/p8-840-spira.dts b/hdata/test/p8-840-spira.dts
index 62a2f52bc..e73c691d4 100644
--- a/hdata/test/p8-840-spira.dts
+++ b/hdata/test/p8-840-spira.dts
@@ -746,7 +746,7 @@
 						description = "16GB CDIMM";
 						ibm,chip-id = <0x0>;
 						ibm,memory-bus-frequency = <0x0 0x0>;
-						size = "0016384";
+						size = "16384";
 					};
 
 					ms-dimm at d002 {
@@ -768,7 +768,7 @@
 						description = "16GB CDIMM";
 						ibm,chip-id = <0x0>;
 						ibm,memory-bus-frequency = <0x0 0x0>;
-						size = "0016384";
+						size = "16384";
 					};
 
 					processor at 1000 {
diff --git a/hdata/test/p81-811.spira.dts b/hdata/test/p81-811.spira.dts
index ba9b3551f..2ca361ee3 100644
--- a/hdata/test/p81-811.spira.dts
+++ b/hdata/test/p81-811.spira.dts
@@ -1899,7 +1899,7 @@
 						description = "32GB CDIMM";
 						ibm,chip-id = <0x0>;
 						ibm,memory-bus-frequency = <0x0 0x0>;
-						size = "0032768";
+						size = "32768";
 					};
 
 					ms-dimm at d002 {
@@ -1921,7 +1921,7 @@
 						description = "32GB CDIMM";
 						ibm,chip-id = <0x0>;
 						ibm,memory-bus-frequency = <0x0 0x0>;
-						size = "0032768";
+						size = "32768";
 					};
 
 					ms-dimm at d008 {
@@ -1943,7 +1943,7 @@
 						description = "32GB CDIMM";
 						ibm,chip-id = <0x10>;
 						ibm,memory-bus-frequency = <0x0 0x0>;
-						size = "0032768";
+						size = "32768";
 					};
 
 					ms-dimm at d00a {
@@ -1965,7 +1965,7 @@
 						description = "32GB CDIMM";
 						ibm,chip-id = <0x10>;
 						ibm,memory-bus-frequency = <0x0 0x0>;
-						size = "0032768";
+						size = "32768";
 					};
 
 					processor at 1000 {
-- 
2.14.3



More information about the Skiboot mailing list