Skip to contentSkip to conversation

maybe bug in common/ddr_spd.c

PATCH 张忠山 3 participants 4 messages Apr 9, 2019 – Apr 11, 2019

lore
Share & tools
lore

张忠山

author
#0 lore raw

Maybe this is a bug, I'm not sure

-----------------------------------8<----------------------------- From 55509f359abbb1f5c24e9f0c2b9cff167f62ae4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= <[email protected]>
Date: Mon, 8 Apr 2019 14:34:00 +0800
Subject: [PATCH] bugfix: check ddr mod_ranks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 common/ddr_spd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/ddr_spd.c +1 -1
index ec343ef5a..277d418e9 100644
@@ -253,7 +253,7 @@ void ddr_spd_print(uint8_t *record)
 		printf("Error module type\n");
 
 	printf("%-48s ", "DRAM Package ");
-	if ((s->mod_ranks & 0x10) == 1)
+	if ((s->mod_ranks & 0x10) != 0)
 		printf("Stack\n");
 	else
 		printf("Planar\n");
Signature · 5 lines
2.21.0
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 21 lines · 张忠山

Maybe this is a bug, I'm not sure

-----------------------------------8<----------------------------- From 55509f359abbb1f5c24e9f0c2b9cff167f62ae4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= <[email protected]>
Date: Mon, 8 Apr 2019 14:34:00 +0800
Subject: [PATCH] bugfix: check ddr mod_ranks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 common/ddr_spd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/ddr_spd.c +0 -0
index ec343ef5a..277d418e9 100644

common/ddr_spd.c void ddr_spd_print(uint8_t *record) · line 256

Quoted 5 lines
common/ddr_spd.c +1 -1
@@ -253,7 +253,7 @@ void ddr_spd_print(uint8_t *record)
 		printf("Error module type\n");
 
 	printf("%-48s ", "DRAM Package ");
-	if ((s->mod_ranks & 0x10) == 1)
+	if ((s->mod_ranks & 0x10) != 0)

For sure this is buggy. Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 24 lines · Sascha Hauer
Quoted 23 lines · 张忠山

Maybe this is a bug, I'm not sure

-----------------------------------8<----------------------------- From 55509f359abbb1f5c24e9f0c2b9cff167f62ae4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= <[email protected]>
Date: Mon, 8 Apr 2019 14:34:00 +0800
Subject: [PATCH] bugfix: check ddr mod_ranks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 common/ddr_spd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/ddr_spd.c +0 -0
index ec343ef5a..277d418e9 100644
@@ -253,7 +253,7 @@ void ddr_spd_print(uint8_t *record)
 		printf("Error module type\n");
 
Quoted 5 lines

common/ddr_spd.c void ddr_spd_print(uint8_t *record) · line 256

Quoted 3 lines
common/ddr_spd.c +1 -1
 	printf("%-48s ", "DRAM Package ");
-	if ((s->mod_ranks & 0x10) == 1)
+	if ((s->mod_ranks & 0x10) != 0)

For sure this is buggy. Applied, thanks

I know it is too late already, but isn't

	if (s->mod_ranks & 0x10)

a bit more usual fix?

ladis

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
Quoted 31 lines · Ladislav Michl
Quoted 24 lines · Sascha Hauer
Quoted 23 lines · 张忠山

Maybe this is a bug, I'm not sure

-----------------------------------8<----------------------------- From 55509f359abbb1f5c24e9f0c2b9cff167f62ae4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BC=A0=E5=BF=A0=E5=B1=B1?= <[email protected]>
Date: Mon, 8 Apr 2019 14:34:00 +0800
Subject: [PATCH] bugfix: check ddr mod_ranks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 common/ddr_spd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/ddr_spd.c +0 -0
index ec343ef5a..277d418e9 100644
@@ -253,7 +253,7 @@ void ddr_spd_print(uint8_t *record)
 		printf("Error module type\n");
 
Quoted 5 lines

common/ddr_spd.c void ddr_spd_print(uint8_t *record) · line 256

Quoted 3 lines
common/ddr_spd.c +1 -1
 	printf("%-48s ", "DRAM Package ");
-	if ((s->mod_ranks & 0x10) == 1)
+	if ((s->mod_ranks & 0x10) != 0)

For sure this is buggy. Applied, thanks

Quoted 3 lines

I know it is too late already, but isn't

	if (s->mod_ranks & 0x10)

a bit more usual fix?

Hmm, actually there's some more comparsion worth verifying as shown bellow:

common/ddr_spd.c +4 -4
index 0ba5eacea..7c9abeead 100644
@@ -256,7 +256,7 @@ void ddr_spd_print(uint8_t *record)
 	ctime = ddr2_sdram_ctime(s->clk_cycle);
 	ddrclk = 2 * (100000 / ctime);
 	tbits = (s->res_7 << 8) + (s->dataw);
-	if ((s->config & 0x03) == 1)
+	if (s->config & 0x01)
 		tbits = tbits - 8;
 
 	pcclk = ddrclk * tbits / 8;
@@ -325,7 +325,7 @@ void ddr_spd_print(uint8_t *record)
 		printf("Error module type\n");
 
 	printf("%-48s ", "DRAM Package ");
-	if ((s->mod_ranks & 0x10) == 1)
+	if (s->mod_ranks & 0x10)
 		printf("Stack\n");
 	else
 		printf("Planar\n");
@@ -341,7 +341,7 @@ void ddr_spd_print(uint8_t *record)
 	if (parity == 0)
 		printf("No Parity\n");
 
-	if ((parity & 0x03) == 0x01)
+	if (parity & 0x01)
 		printf("Data Parity\n");
 	if (parity & 0x02)
 		printf("Data ECC\n");
@@ -349,7 +349,7 @@ void ddr_spd_print(uint8_t *record)
 	if (parity & 0x04)
 		printf("Address/Command Parity\n");
 
-	if ((s->refresh >> 7) == 1)
+	if (s->refresh & 0x80)
 		ref = "- Self Refresh";
 	else
 		ref = " ";

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox