Blame SOURCES/0039-devtree-Correctly-read-size-for-DDR4-SPD.patch

99c779
From ab43c697ebaff3e5138c43a39a17f69859cde87d Mon Sep 17 00:00:00 2001
99c779
From: Jeremy Kerr <jk@ozlabs.org>
99c779
Date: Tue, 6 Sep 2016 14:11:34 +0800
99c779
Subject: [PATCH 39/43] devtree: Correctly read size for DDR4 SPD
99c779
99c779
We may have up to 512 bytes of SPD now, so bump dimminfo_buf.
99c779
99c779
This will mean our offsets can be larger than 256 bytes, so use a
99c779
uint16_t here.
99c779
99c779
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
99c779
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
99c779
---
99c779
 src/core/device-tree.cc | 26 +++++++++++++++-----------
99c779
 1 file changed, 15 insertions(+), 11 deletions(-)
99c779
99c779
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
99c779
index b7d0d57..2672b53 100644
99c779
--- a/src/core/device-tree.cc
99c779
+++ b/src/core/device-tree.cc
99c779
@@ -32,7 +32,7 @@
99c779
 
99c779
 __ID("@(#) $Id$");
99c779
 
99c779
-#define DIMMINFOSIZE 0x100
99c779
+#define DIMMINFOSIZE 0x200
99c779
 typedef uint8_t dimminfo_buf[DIMMINFOSIZE];
99c779
 
99c779
 struct dimminfo
99c779
@@ -807,14 +807,14 @@ static bool add_memory_bank_mba_dimm(string path,
99c779
 static void add_memory_bank_spd(string path, hwNode & bank)
99c779
 {
99c779
   char dimmversion[20];
99c779
-  unsigned char mfg_loc_offset;
99c779
-  unsigned char rev_offset1;
99c779
-  unsigned char rev_offset2;
99c779
-  unsigned char year_offset;
99c779
-  unsigned char week_offset;
99c779
-  unsigned char partno_offset;
99c779
-  unsigned char ver_offset;
99c779
-  unsigned char serial_offset;
99c779
+  uint16_t mfg_loc_offset;
99c779
+  uint16_t rev_offset1;
99c779
+  uint16_t rev_offset2;
99c779
+  uint16_t year_offset;
99c779
+  uint16_t week_offset;
99c779
+  uint16_t partno_offset;
99c779
+  uint16_t ver_offset;
99c779
+  uint16_t serial_offset;
99c779
   int fd;
99c779
   size_t len = 0;
99c779
   dimminfo_buf dimminfo;
99c779
@@ -830,9 +830,13 @@ static void add_memory_bank_spd(string path, hwNode & bank)
99c779
   }
99c779
 
99c779
   /* Read entire SPD eeprom */
99c779
-  if (dimminfo[2] >= 9) /* DDR3 */
99c779
+  if (dimminfo[2] >= 9) /* DDR3 & DDR4 */
99c779
   {
99c779
-    len = 64 << ((dimminfo[0] & 0x70) >> 4);
99c779
+    uint8_t val = (dimminfo[0] >> 4) & 0x7;
99c779
+    if (val == 1)
99c779
+      len = 256;
99c779
+    else if (val == 2)
99c779
+      len = 512;
99c779
   } else if (dimminfo[0] < 15) { /* DDR 2 */
99c779
     len = 1 << dimminfo[1];
99c779
   }
99c779
-- 
99c779
2.10.2
99c779