aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core
diff options
context:
space:
mode:
authorWolfram Sang <wsa@the-dreams.de>2013-11-25 20:16:25 -0500
committerChris Ball <chris@printf.net>2014-01-13 14:02:35 -0500
commit9288cac05405a7da406097a44721aa4004609b4d (patch)
tree1f01e31ac29fb7ee6b63e4b49d374896587f6acb /drivers/mmc/core
parent9e7861f500ea2777c82e69b77b965fb8220cd1c5 (diff)
mmc: core: sd: implement proper support for sd3.0 au sizes
This reverts and updates commit 77776fd0a4cc541b9 ("mmc: sd: fix the maximum au_size for SD3.0"). The au_size for SD3.0 cannot be achieved by a simple bit shift, so this needs to be implemented differently. Also, don't print the warning in case of 0 since 'not defined' is different from 'invalid'. Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Acked-by: Jaehoon Chung <jh80.chung@samsung.com> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: stable <stable@vger.kernel.org> # [3.12, 3.13] Signed-off-by: Chris Ball <chris@printf.net>
Diffstat (limited to 'drivers/mmc/core')
-rw-r--r--drivers/mmc/core/sd.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 6f42050b7ccc..692fdb177294 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/sizes.h>
14#include <linux/slab.h> 15#include <linux/slab.h>
15#include <linux/stat.h> 16#include <linux/stat.h>
16#include <linux/pm_runtime.h> 17#include <linux/pm_runtime.h>
@@ -45,6 +46,13 @@ static const unsigned int tacc_mant[] = {
45 35, 40, 45, 50, 55, 60, 70, 80, 46 35, 40, 45, 50, 55, 60, 70, 80,
46}; 47};
47 48
49static const unsigned int sd_au_size[] = {
50 0, SZ_16K / 512, SZ_32K / 512, SZ_64K / 512,
51 SZ_128K / 512, SZ_256K / 512, SZ_512K / 512, SZ_1M / 512,
52 SZ_2M / 512, SZ_4M / 512, SZ_8M / 512, (SZ_8M + SZ_4M) / 512,
53 SZ_16M / 512, (SZ_16M + SZ_8M) / 512, SZ_32M / 512, SZ_64M / 512,
54};
55
48#define UNSTUFF_BITS(resp,start,size) \ 56#define UNSTUFF_BITS(resp,start,size) \
49 ({ \ 57 ({ \
50 const int __size = size; \ 58 const int __size = size; \
@@ -216,7 +224,7 @@ static int mmc_decode_scr(struct mmc_card *card)
216static int mmc_read_ssr(struct mmc_card *card) 224static int mmc_read_ssr(struct mmc_card *card)
217{ 225{
218 unsigned int au, es, et, eo; 226 unsigned int au, es, et, eo;
219 int err, i, max_au; 227 int err, i;
220 u32 *ssr; 228 u32 *ssr;
221 229
222 if (!(card->csd.cmdclass & CCC_APP_SPEC)) { 230 if (!(card->csd.cmdclass & CCC_APP_SPEC)) {
@@ -240,26 +248,25 @@ static int mmc_read_ssr(struct mmc_card *card)
240 for (i = 0; i < 16; i++) 248 for (i = 0; i < 16; i++)
241 ssr[i] = be32_to_cpu(ssr[i]); 249 ssr[i] = be32_to_cpu(ssr[i]);
242 250
243 /* SD3.0 increases max AU size to 64MB (0xF) from 4MB (0x9) */
244 max_au = card->scr.sda_spec3 ? 0xF : 0x9;
245
246 /* 251 /*
247 * UNSTUFF_BITS only works with four u32s so we have to offset the 252 * UNSTUFF_BITS only works with four u32s so we have to offset the
248 * bitfield positions accordingly. 253 * bitfield positions accordingly.
249 */ 254 */
250 au = UNSTUFF_BITS(ssr, 428 - 384, 4); 255 au = UNSTUFF_BITS(ssr, 428 - 384, 4);
251 if (au > 0 && au <= max_au) { 256 if (au) {
252 card->ssr.au = 1 << (au + 4); 257 if (au <= 9 || card->scr.sda_spec3) {
253 es = UNSTUFF_BITS(ssr, 408 - 384, 16); 258 card->ssr.au = sd_au_size[au];
254 et = UNSTUFF_BITS(ssr, 402 - 384, 6); 259 es = UNSTUFF_BITS(ssr, 408 - 384, 16);
255 eo = UNSTUFF_BITS(ssr, 400 - 384, 2); 260 et = UNSTUFF_BITS(ssr, 402 - 384, 6);
256 if (es && et) { 261 if (es && et) {
257 card->ssr.erase_timeout = (et * 1000) / es; 262 eo = UNSTUFF_BITS(ssr, 400 - 384, 2);
258 card->ssr.erase_offset = eo * 1000; 263 card->ssr.erase_timeout = (et * 1000) / es;
264 card->ssr.erase_offset = eo * 1000;
265 }
266 } else {
267 pr_warning("%s: SD Status: Invalid Allocation Unit size.\n",
268 mmc_hostname(card->host));
259 } 269 }
260 } else {
261 pr_warning("%s: SD Status: Invalid Allocation Unit "
262 "size.\n", mmc_hostname(card->host));
263 } 270 }
264out: 271out:
265 kfree(ssr); 272 kfree(ssr);