Linux-mmc Archive on lore.kernel.org
 help / color / Atom feed
From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
To: linux-mmc@vger.kernel.org
Subject: mmc-utils mmc tool reports incorrect cache size
Date: Thu, 13 Feb 2020 08:34:43 +1100
Message-ID: <CAEg67GnNdOBgq=gVH9fDTwT0-KM5+3g8Do5ZnW+y6Q0AY_302A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

Hi,

I recently noticed that 'mmc' reports cache size incorrectly. The unit
in the extended CSD is kilobits rather than kilobytes, so for a
display unit of 'KiB' it needs to be scaled appropriately.
Alternatively the unit could change to Kibit, but I think that's less
helpful.

I've attached a patch which fixes the issue & includes references to
the relevant parts of the JEDEC standard.

Hope someone finds this helpful,

Patrick

[-- Attachment #2: 0001-Scale-ext_csd-cache-size-from-kilobits-to-kilobytes.patch --]
[-- Type: text/x-patch, Size: 1133 bytes --]

From fd741374278ec64bb0c26780d043fab0d7bcf40e Mon Sep 17 00:00:00 2001
From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Date: Mon, 4 Nov 2019 13:51:12 +1100
Subject: [PATCH] Scale ext_csd cache size from kilobits to kilobytes

JESD84-B51 7.4.30 CACHE_SIZE [252:249] states that "the size is
indicated as multiple of kilobits". This is also supported by Table 39,
"e.MMC internal sizes and related Units / Granularities" which lists
"32Kb (=4KB)" as the cache size granularity for 4KiB native devices.
---
 mmc_cmds.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mmc_cmds.c b/mmc_cmds.c
index fb37189..a1b1d75 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -1419,8 +1419,8 @@ int do_read_extcsd(int nargs, char **argv)
 		printf("Power off notification [POWER_OFF_LONG_TIME: 0x%02x]\n",
 			ext_csd[247]);
 		printf("Cache Size [CACHE_SIZE] is %d KiB\n",
-			ext_csd[249] << 0 | (ext_csd[250] << 8) |
-			(ext_csd[251] << 16) | (ext_csd[252] << 24));
+			(ext_csd[249] << 0 | (ext_csd[250] << 8) |
+			(ext_csd[251] << 16) | (ext_csd[252] << 24)) / 8);
 	}
 
 	/* A441: Reserved [501:247]
-- 
2.23.0


             reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 21:34 Patrick Oppenlander [this message]
2020-02-13  7:35 ` Avri Altman
2020-02-13 22:14   ` Patrick Oppenlander

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEg67GnNdOBgq=gVH9fDTwT0-KM5+3g8Do5ZnW+y6Q0AY_302A@mail.gmail.com' \
    --to=patrick.oppenlander@gmail.com \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-mmc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mmc/0 linux-mmc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mmc linux-mmc/ https://lore.kernel.org/linux-mmc \
		linux-mmc@vger.kernel.org
	public-inbox-index linux-mmc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mmc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git