Skip to contentSkip to conversation

MCI print revision

PATCH Applied Alexander Shiyan 3 participants 8 messages May 30, 2016 – Jun 7, 2016

lore
Share & tools
lore
#1 lore raw

+Cc Trent

Quoted 8 lines · Alexander Shiyan

Hello.

Commit dbd7190295298acfb4996ec1aba5165a7be28fdc (mci: Print versions with micro levels correctly) seems to be incorrect.

barebox@Informer:/ mmc0.probe=1
mmc0: detected SD card version 1.a
mmc0: registered mmc0

So what's the expected printout and was it correct without this patch?

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 7 lines

Вторник, 31 мая 2016, 9:26 +03:00 от Sascha Hauer <[email protected]>:

+Cc Trent

Quoted 2 lines · Alexander Shiyan

Hello.

Quoted 8 lines
Quoted 6 lines

Commit dbd7190295298acfb4996ec1aba5165a7be28fdc (mci: Print versions with micro levels correctly) seems to be incorrect.

barebox@Informer:/ mmc0.probe=1
mmc0: detected SD card version 1.a
mmc0: registered mmc0

So what's the expected printout and was it correct without this patch?

Host information:
current clock: 25000000
current buswidth: 4
capabilities: 4bit sd-hs mmc-hs
Card information:
Attached is an SD Card (Version: 1.10)
Capacity: 1962 MiB
CID: 1C535653-44432020-1000013C-7E007200
CSD: 005E0032-5F5A83D5-2DB7FFBF-96800000
Max. transfer speed: 25000000 Hz
capabilities: 4bit sd-hs
Manufacturer ID: 1C
OEM/Application ID: 5356
Product name: 'SDC '
Product revision: 1.0
Serial no: 3086991254
Manufacturing date: 2.2007
...

So, expected 1.1

---

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

#3 lore raw
Quoted 14 lines · Alexander Shiyan
Quoted 14 lines

Вторник, 31 мая 2016, 9:26 +03:00 от Sascha Hauer <[email protected]>:

+Cc Trent

Quoted 8 lines · Alexander Shiyan

Hello.

Commit dbd7190295298acfb4996ec1aba5165a7be28fdc (mci: Print versions with micro levels correctly) seems to be incorrect.

barebox@Informer:/ mmc0.probe=1
mmc0: detected SD card version 1.a
mmc0: registered mmc0

Quoted 8 lines
Quoted 1 line

So what's the expected printout and was it correct without this patch?

Host information:
current clock: 25000000
current buswidth: 4
capabilities: 4bit sd-hs mmc-hs
Card information:
Attached is an SD Card (Version: 1.10)

So the %x for printing the minor should really be a %u?

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
#4 lore raw
Quoted 19 lines

Вторник, 31 мая 2016, 10:23 +03:00 от Sascha Hauer <[email protected]>:

Quoted 16 lines · Alexander Shiyan
Quoted 15 lines

Вторник, 31 мая 2016, 9:26 +03:00 от Sascha Hauer <[email protected]>:

+Cc Trent

Quoted 8 lines · Alexander Shiyan

Hello.

Commit dbd7190295298acfb4996ec1aba5165a7be28fdc (mci: Print versions with micro levels correctly) seems to be incorrect.

barebox@Informer:/ mmc0.probe=1
mmc0: detected SD card version 1.a
mmc0: registered mmc0

So what's the expected printout and was it correct without this patch?

Quoted 8 lines
Quoted 6 lines

Host information:
current clock: 25000000
current buswidth: 4
capabilities: 4bit sd-hs mmc-hs
Card information:
Attached is an SD Card (Version: 1.10)

So the %x for printing the minor should really be a %u?

I think yes. AFAIK there is no "1a" revision for SD card, but 1.01 and 1.1 is correct.

---

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

#5 lore raw
In reply to Sascha Hauer
Quoted 17 lines · Sascha Hauer
Quoted 16 lines · Alexander Shiyan
Quoted 15 lines

Вторник, 31 мая 2016, 9:26 +03:00 от Sascha Hauer <[email protected]>:

+Cc Trent

Quoted 8 lines · Alexander Shiyan

Hello.

Commit dbd7190295298acfb4996ec1aba5165a7be28fdc (mci: Print versions with micro levels correctly) seems to be incorrect.

barebox@Informer:/ mmc0.probe=1
mmc0: detected SD card version 1.a
mmc0: registered mmc0

So what's the expected printout and was it correct without this patch?

Quoted 8 lines
Quoted 6 lines

Host information:
current clock: 25000000
current buswidth: 4
capabilities: 4bit sd-hs mmc-hs
Card information:
Attached is an SD Card (Version: 1.10)

So the %x for printing the minor should really be a %u?

No, that will print MMC version 4.41 incorrectly as 4.65.

I think the issue is the value of the version codes and how they should be printed. AFAICT, the codes originated in u-boot but were changed in commit "mci: Fix version handling" in 2014. The original u-boot code was easier to print, using "0x429" for version 4.41 so it would print correctly with "%u", but since 0x29 > 0x05 this resulted in 4.41 being sorted after 4.5. I think the fundamental problem here is fault of the people who created the SD and eMMC standards giving us this:
1.10 > 1.01
4.41 < 4.5

It's just not consistent. In one case the last two digits are single number but in the other they are a minor,micro version pair.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#6 lore raw

PATCH 1/1 mci: Fix version numbers again

The SD and eMMC version numbers are a pain to print and sort, since they are inconsistent in if a two digit minor version shdoulde be treated as a single number or as minor and micro version numbers.

This allows version 1.10 and 4.5 and 4.41, where 41 is less than 5.

---
 drivers/mci/mci-core.c | 14 +++++++++-----
 include/mci.h          |  7 ++++++-
 2 files changed, 15 insertions(+), 6 deletions(-)
drivers/mci/mci-core.c +9 -5
index 59f6675..42dde06 100644
@@ -949,14 +949,18 @@ out:
 
 static char *mci_version_string(struct mci *mci)
 {
-	static char version[sizeof("x.xx")];
-	unsigned major, minor;
+	static char version[sizeof("xx.xxx")];
+	unsigned major, minor, micro;
+	int n;
 
 	major = (mci->version >> 8) & 0xf;
-	minor = mci->version & 0xff;
+	minor = (mci->version >> 4) & 0xf;
+	micro = mci->version & 0xf;
 
-	/* Shift off last digit of minor if it's 0 */
-	sprintf(version, "%u.%x", major, minor & 0xf ? minor : minor >> 4);
+	n = sprintf(version, "%u.%u", major, minor);
+	/* Omit zero micro versions */
+	if (micro)
+		sprintf(version + n, "%u", micro);
 
 	return version;
 }
include/mci.h +6 -1
index 174d150..001c86c 100644
@@ -30,11 +30,16 @@
 #include <block.h>
 #include <regulator.h>
 
+/* These codes should be sorted numerically in order of newness.  If the last
+ * nybble is a zero, it will not be printed.  So 0x120 -> "1.2" and 0x123 ->
+ * "1.23", 0x1a0 -> "1.10", 0x1b0 and 0x111 -> "1.11" but sort differently.
+ * It's not possible to create "1.20".  */
+
 /* Firmware revisions for SD cards */
 #define SD_VERSION_SD		0x20000
-#define SD_VERSION_2		(SD_VERSION_SD | 0x200)
 #define SD_VERSION_1_0		(SD_VERSION_SD | 0x100)
 #define SD_VERSION_1_10		(SD_VERSION_SD | 0x1a0)
+#define SD_VERSION_2		(SD_VERSION_SD | 0x200)
 
 /* Firmware revisions for MMC cards */
 #define MMC_VERSION_MMC		0x10000
Signature · 7 lines
2.7.0.25.gfc10eb5.dirty


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#7 lore raw

Re: [PATCH] mci: Fix version numbers again

Quoted 8 lines · Trent Piepho

The SD and eMMC version numbers are a pain to print and sort, since they are inconsistent in if a two digit minor version shdoulde be treated as a single number or as minor and micro version numbers.

This allows version 1.10 and 4.5 and 4.41, where 41 is less than 5.

---

Applied, thanks

Sascha

Quoted 58 lines
 drivers/mci/mci-core.c | 14 +++++++++-----
 include/mci.h          |  7 ++++++-
 2 files changed, 15 insertions(+), 6 deletions(-)
drivers/mci/mci-core.c +9 -5
index 59f6675..42dde06 100644
@@ -949,14 +949,18 @@ out:
 
 static char *mci_version_string(struct mci *mci)
 {
-	static char version[sizeof("x.xx")];
-	unsigned major, minor;
+	static char version[sizeof("xx.xxx")];
+	unsigned major, minor, micro;
+	int n;
 
 	major = (mci->version >> 8) & 0xf;
-	minor = mci->version & 0xff;
+	minor = (mci->version >> 4) & 0xf;
+	micro = mci->version & 0xf;
 
-	/* Shift off last digit of minor if it's 0 */
-	sprintf(version, "%u.%x", major, minor & 0xf ? minor : minor >> 4);
+	n = sprintf(version, "%u.%u", major, minor);
+	/* Omit zero micro versions */
+	if (micro)
+		sprintf(version + n, "%u", micro);
 
 	return version;
 }
include/mci.h +6 -1
index 174d150..001c86c 100644
@@ -30,11 +30,16 @@
 #include <block.h>
 #include <regulator.h>
 
+/* These codes should be sorted numerically in order of newness.  If the last
+ * nybble is a zero, it will not be printed.  So 0x120 -> "1.2" and 0x123 ->
+ * "1.23", 0x1a0 -> "1.10", 0x1b0 and 0x111 -> "1.11" but sort differently.
+ * It's not possible to create "1.20".  */
+
 /* Firmware revisions for SD cards */
 #define SD_VERSION_SD		0x20000
-#define SD_VERSION_2		(SD_VERSION_SD | 0x200)
 #define SD_VERSION_1_0		(SD_VERSION_SD | 0x100)
 #define SD_VERSION_1_10		(SD_VERSION_SD | 0x1a0)
+#define SD_VERSION_2		(SD_VERSION_SD | 0x200)
 
 /* Firmware revisions for MMC cards */
 #define MMC_VERSION_MMC		0x10000
Signature · 1 line
2.7.0.25.gfc10eb5.dirty
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