From patchwork Sat Mar 5 12:15:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 391 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:42:07 -0000 Delivered-To: patches@linaro.org Received: by 10.224.60.68 with SMTP id o4cs45945qah; Sat, 5 Mar 2011 04:16:26 -0800 (PST) Received: by 10.213.107.79 with SMTP id a15mr312924ebp.86.1299327384686; Sat, 05 Mar 2011 04:16:24 -0800 (PST) Received: from eu1sys200aog105.obsmtp.com (eu1sys200aog105.obsmtp.com [207.126.144.119]) by mx.google.com with SMTP id k50si886547eei.97.2011.03.05.04.16.18 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 Mar 2011 04:16:24 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.119 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.119; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.119 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from source ([138.198.100.35]) (using TLSv1) by eu1sys200aob105.postini.com ([207.126.147.11]) with SMTP ID DSNKTXIpipmuSS4rwjUcBJ5kgrVDed7AAJTv@postini.com; Sat, 05 Mar 2011 12:16:24 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 98381FB; Sat, 5 Mar 2011 12:15:52 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 481F85EF; Sat, 5 Mar 2011 12:15:52 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id D23C3A8065; Sat, 5 Mar 2011 13:15:46 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.2.254.0; Sat, 5 Mar 2011 13:15:51 +0100 From: Linus Walleij To: , Chris Ball Cc: Lee Jones , Linus Walleij , Gary King , Ulf Hansson , Linus Walleij Subject: [PATCH] mmc: subtract boot sectors from disk size for eMMC 4.3+ devices Date: Sat, 5 Mar 2011 13:15:44 +0100 Message-ID: <1299327344-12462-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 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 Signed-off-by: Ulf Hansson Signed-off-by: Linus Walleij --- 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 */