diff mbox series

[1/7] mmc-utils: interpret OPTIMAL_*_SIZE fields in extcsd

Message ID 4a016f761d388a989059467507f2bc948ba26c6c.1539103468.git.jamesnuss@nanometrics.ca (mailing list archive)
State New, archived
Headers show
Series fix bugs in write_reliability and enh_area set commands + more extcsd parsing | expand

Commit Message

James Nuss Oct. 9, 2018, 5:31 p.m. UTC
eMMC 5.0 introduced OPTIMAL_READ_SIZE, OPTIMAL_WRITE_SIZE and OPTIMAL
TRIM_UNIT_SIZE fields in the extcsd

Interpret these fields when reading out the extcsd with human-readable
results

Signed-off-by: James Nuss <jamesnuss@nanometrics.ca>
---
 mmc.h      |  3 +++
 mmc_cmds.c | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

Comments

Avri Altman Oct. 10, 2018, 8:40 a.m. UTC | #1
Looks fine.

Thanks,
Avri

> eMMC 5.0 introduced OPTIMAL_READ_SIZE, OPTIMAL_WRITE_SIZE and
> OPTIMAL
> TRIM_UNIT_SIZE fields in the extcsd
> 
> Interpret these fields when reading out the extcsd with human-readable
> results
> 
> Signed-off-by: James Nuss <jamesnuss@nanometrics.ca>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Christoph Fritz Nov. 4, 2019, 9:57 p.m. UTC | #2
On Wed, 2018-10-10 at 08:40 +0000, Avri Altman wrote:
> Looks fine.
> 
> Thanks,
> Avri
> 
> > eMMC 5.0 introduced OPTIMAL_READ_SIZE, OPTIMAL_WRITE_SIZE and
> > OPTIMAL
> > TRIM_UNIT_SIZE fields in the extcsd
> > 
> > Interpret these fields when reading out the extcsd with human-readable
> > results
> > 
> > Signed-off-by: James Nuss <jamesnuss@nanometrics.ca>
> Reviewed-by: Avri Altman <avri.altman@wdc.com>

Hi Chris,

 are there any objections adding this and most of the other patches from
James?


  -- Christoph
diff mbox series

Patch

diff --git a/mmc.h b/mmc.h
index 285c1f1..5d8a7e3 100644
--- a/mmc.h
+++ b/mmc.h
@@ -56,6 +56,9 @@ 
 #define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B 	269	/* RO */
 #define EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A 	268	/* RO */
 #define EXT_CSD_PRE_EOL_INFO		267	/* RO */
+#define EXT_CSD_OPTIMAL_READ_SIZE	266	/* RO */
+#define EXT_CSD_OPTIMAL_WRITE_SIZE	265	/* RO */
+#define EXT_CSD_OPTIMAL_TRIM_UNIT_SIZE	264	/* RO */
 #define EXT_CSD_FIRMWARE_VERSION	254	/* RO */
 #define EXT_CSD_CACHE_SIZE_3		252
 #define EXT_CSD_CACHE_SIZE_2		251
diff --git a/mmc_cmds.c b/mmc_cmds.c
index 44623fe..97ea111 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -1766,6 +1766,24 @@  int do_read_extcsd(int nargs, char **argv)
 			ext_csd[EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]);
 		printf("eMMC Pre EOL information [EXT_CSD_PRE_EOL_INFO]: 0x%02x\n",
 			ext_csd[EXT_CSD_PRE_EOL_INFO]);
+
+		reg = ext_csd[EXT_CSD_OPTIMAL_READ_SIZE];
+		printf("Minimum optimal read unit size (for the device) "
+			"[OPTIMAL_READ_SIZE]: 0x%02x\n", reg);
+		printf(" i.e. %lu KiB\n", reg * 4UL);
+
+		reg = ext_csd[EXT_CSD_OPTIMAL_WRITE_SIZE];
+		printf("Minimum optimal write unit size (for the device) "
+			"[OPTIMAL_WRITE_SIZE]: 0x%02x\n", reg);
+		printf(" i.e. %lu KiB\n", reg * 4UL);
+
+		reg = ext_csd[EXT_CSD_OPTIMAL_TRIM_UNIT_SIZE];
+		printf("Minimum optimal trim unit size (for the device) "
+			"[OPTIMAL_TRIM_UNIT_SIZE]: 0x%02x\n", reg);
+		if (reg == 0 || reg > 21)
+			printf("error: invalid OPTIMAL_TRIM_UNIT_SIZE\n");
+		else
+			printf(" i.e. %lu KiB\n", (1UL << (reg - 1)) * 4);
 	}
 
 	if (ext_csd_rev >= 8) {