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

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