Linus Walleij
2011-03-05 12:15:44 UTC
This patch is a squash of patches from Gary King and Ulf
Hansson done in Android trees, hopefully fixing the issue properly.
The csd sector count reported by eMMC 4.3+ cards includes the boot
partition size; subtract this from the size reported to the disk
since the boot partition is inaccessible.
Signed-off-by: Gary King <***@nvidia.com>
Signed-off-by: Ulf Hansson <***@stericsson.com>
Signed-off-by: Linus Walleij <***@linaro.org>
---
drivers/mmc/core/mmc.c | 7 +++++++
include/linux/mmc/mmc.h | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 14e95f3..03c3283 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -255,6 +255,13 @@ static int mmc_read_ext_csd(struct mmc_card *card)
/* Cards with density > 2GiB are sector addressed */
if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512)
mmc_card_set_blockaddr(card);
+
+ if (card->ext_csd.sectors) {
+ unsigned boot_sectors;
+ /* size is in 256K chunks, i.e. 512 sectors each */
+ boot_sectors = ext_csd[EXT_CSD_BOOT_SIZE_MULTI] * 512;
+ card->ext_csd.sectors -= boot_sectors;
+ }
}
switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) {
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 264ba54..4516fc1 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -267,6 +267,7 @@ struct _mmc_csd {
#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */
#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */
#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
+#define EXT_CSD_BOOT_SIZE_MULTI 226 /* RO */
#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */
#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */
#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
Hansson done in Android trees, hopefully fixing the issue properly.
The csd sector count reported by eMMC 4.3+ cards includes the boot
partition size; subtract this from the size reported to the disk
since the boot partition is inaccessible.
Signed-off-by: Gary King <***@nvidia.com>
Signed-off-by: Ulf Hansson <***@stericsson.com>
Signed-off-by: Linus Walleij <***@linaro.org>
---
drivers/mmc/core/mmc.c | 7 +++++++
include/linux/mmc/mmc.h | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 14e95f3..03c3283 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -255,6 +255,13 @@ static int mmc_read_ext_csd(struct mmc_card *card)
/* Cards with density > 2GiB are sector addressed */
if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512)
mmc_card_set_blockaddr(card);
+
+ if (card->ext_csd.sectors) {
+ unsigned boot_sectors;
+ /* size is in 256K chunks, i.e. 512 sectors each */
+ boot_sectors = ext_csd[EXT_CSD_BOOT_SIZE_MULTI] * 512;
+ card->ext_csd.sectors -= boot_sectors;
+ }
}
switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) {
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 264ba54..4516fc1 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -267,6 +267,7 @@ struct _mmc_csd {
#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */
#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */
#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
+#define EXT_CSD_BOOT_SIZE_MULTI 226 /* RO */
#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */
#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */
#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
--
1.7.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
1.7.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html