Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc:
mmc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined
mmc: sdhci-s3c: Remove old and misprototyped suspend operations
mmc: tmio: fix clock gating on platforms with a .set_pwr() method
mmc: sh_mmcif: fix clock gating on platforms with a .down_pwr() method
mmc: core: Fix typo at mmc_card_sleep
mmc: core: Fix power_off_notify during suspend
mmc: core: Fix setting power notify state variable for non-eMMC
mmc: core: Add quirk for long data read time
mmc: Add module.h include to sdhci-cns3xxx.c
mmc: mxcmmc: fix falling back to PIO
mmc: omap_hsmmc: DMA unmap only once in case of MMC error

+95 -44
+8
drivers/mmc/card/block.c
··· 1606 1606 MMC_QUIRK_BLK_NO_CMD23), 1607 1607 MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc, 1608 1608 MMC_QUIRK_BLK_NO_CMD23), 1609 + 1610 + /* 1611 + * Some Micron MMC cards needs longer data read timeout than 1612 + * indicated in CSD. 1613 + */ 1614 + MMC_FIXUP(CID_NAME_ANY, 0x13, 0x200, add_quirk_mmc, 1615 + MMC_QUIRK_LONG_READ_TIME), 1616 + 1609 1617 END_FIXUP 1610 1618 }; 1611 1619
+64 -34
drivers/mmc/core/core.c
··· 529 529 data->timeout_clks = 0; 530 530 } 531 531 } 532 + 533 + /* 534 + * Some cards require longer data read timeout than indicated in CSD. 535 + * Address this by setting the read timeout to a "reasonably high" 536 + * value. For the cards tested, 300ms has proven enough. If necessary, 537 + * this value can be increased if other problematic cards require this. 538 + */ 539 + if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) { 540 + data->timeout_ns = 300000000; 541 + data->timeout_clks = 0; 542 + } 543 + 532 544 /* 533 545 * Some cards need very high timeouts if driven in SPI mode. 534 546 * The worst observed timeout was 900ms after writing a ··· 1225 1213 mmc_host_clk_release(host); 1226 1214 } 1227 1215 1216 + static void mmc_poweroff_notify(struct mmc_host *host) 1217 + { 1218 + struct mmc_card *card; 1219 + unsigned int timeout; 1220 + unsigned int notify_type = EXT_CSD_NO_POWER_NOTIFICATION; 1221 + int err = 0; 1222 + 1223 + card = host->card; 1224 + 1225 + /* 1226 + * Send power notify command only if card 1227 + * is mmc and notify state is powered ON 1228 + */ 1229 + if (card && mmc_card_mmc(card) && 1230 + (card->poweroff_notify_state == MMC_POWERED_ON)) { 1231 + 1232 + if (host->power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { 1233 + notify_type = EXT_CSD_POWER_OFF_SHORT; 1234 + timeout = card->ext_csd.generic_cmd6_time; 1235 + card->poweroff_notify_state = MMC_POWEROFF_SHORT; 1236 + } else { 1237 + notify_type = EXT_CSD_POWER_OFF_LONG; 1238 + timeout = card->ext_csd.power_off_longtime; 1239 + card->poweroff_notify_state = MMC_POWEROFF_LONG; 1240 + } 1241 + 1242 + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1243 + EXT_CSD_POWER_OFF_NOTIFICATION, 1244 + notify_type, timeout); 1245 + 1246 + if (err && err != -EBADMSG) 1247 + pr_err("Device failed to respond within %d poweroff " 1248 + "time. Forcefully powering down the device\n", 1249 + timeout); 1250 + 1251 + /* Set the card state to no notification after the poweroff */ 1252 + card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION; 1253 + } 1254 + } 1255 + 1228 1256 /* 1229 1257 * Apply power to the MMC stack. This is a two-stage process. 1230 1258 * First, we enable power to the card without the clock running. ··· 1321 1269 1322 1270 void mmc_power_off(struct mmc_host *host) 1323 1271 { 1324 - struct mmc_card *card; 1325 - unsigned int notify_type; 1326 - unsigned int timeout; 1327 - int err; 1328 - 1329 1272 mmc_host_clk_hold(host); 1330 1273 1331 - card = host->card; 1332 1274 host->ios.clock = 0; 1333 1275 host->ios.vdd = 0; 1334 1276 1335 - if (card && mmc_card_mmc(card) && 1336 - (card->poweroff_notify_state == MMC_POWERED_ON)) { 1337 - 1338 - if (host->power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { 1339 - notify_type = EXT_CSD_POWER_OFF_SHORT; 1340 - timeout = card->ext_csd.generic_cmd6_time; 1341 - card->poweroff_notify_state = MMC_POWEROFF_SHORT; 1342 - } else { 1343 - notify_type = EXT_CSD_POWER_OFF_LONG; 1344 - timeout = card->ext_csd.power_off_longtime; 1345 - card->poweroff_notify_state = MMC_POWEROFF_LONG; 1346 - } 1347 - 1348 - err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1349 - EXT_CSD_POWER_OFF_NOTIFICATION, 1350 - notify_type, timeout); 1351 - 1352 - if (err && err != -EBADMSG) 1353 - pr_err("Device failed to respond within %d poweroff " 1354 - "time. Forcefully powering down the device\n", 1355 - timeout); 1356 - 1357 - /* Set the card state to no notification after the poweroff */ 1358 - card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION; 1359 - } 1277 + mmc_poweroff_notify(host); 1360 1278 1361 1279 /* 1362 1280 * Reset ocr mask to be the highest possible voltage supported for ··· 2218 2196 2219 2197 mmc_bus_get(host); 2220 2198 2221 - if (host->bus_ops && !host->bus_dead && host->bus_ops->awake) 2199 + if (host->bus_ops && !host->bus_dead && host->bus_ops->sleep) 2222 2200 err = host->bus_ops->sleep(host); 2223 2201 2224 2202 mmc_bus_put(host); ··· 2324 2302 * pre-claim the host. 2325 2303 */ 2326 2304 if (mmc_try_claim_host(host)) { 2327 - if (host->bus_ops->suspend) 2305 + if (host->bus_ops->suspend) { 2306 + /* 2307 + * For eMMC 4.5 device send notify command 2308 + * before sleep, because in sleep state eMMC 4.5 2309 + * devices respond to only RESET and AWAKE cmd 2310 + */ 2311 + mmc_poweroff_notify(host); 2328 2312 err = host->bus_ops->suspend(host); 2313 + } 2314 + mmc_do_release_host(host); 2315 + 2329 2316 if (err == -ENOSYS || !host->bus_ops->resume) { 2330 2317 /* 2331 2318 * We simply "remove" the card in this case. ··· 2349 2318 host->pm_flags = 0; 2350 2319 err = 0; 2351 2320 } 2352 - mmc_do_release_host(host); 2353 2321 } else { 2354 2322 err = -EBUSY; 2355 2323 }
+8 -4
drivers/mmc/core/mmc.c
··· 876 876 * set the notification byte in the ext_csd register of device 877 877 */ 878 878 if ((host->caps2 & MMC_CAP2_POWEROFF_NOTIFY) && 879 - (card->poweroff_notify_state == MMC_NO_POWER_NOTIFICATION)) { 879 + (card->ext_csd.rev >= 6)) { 880 880 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 881 881 EXT_CSD_POWER_OFF_NOTIFICATION, 882 882 EXT_CSD_POWER_ON, 883 883 card->ext_csd.generic_cmd6_time); 884 884 if (err && err != -EBADMSG) 885 885 goto free_card; 886 - } 887 886 888 - if (!err) 889 - card->poweroff_notify_state = MMC_POWERED_ON; 887 + /* 888 + * The err can be -EBADMSG or 0, 889 + * so check for success and update the flag 890 + */ 891 + if (!err) 892 + card->poweroff_notify_state = MMC_POWERED_ON; 893 + } 890 894 891 895 /* 892 896 * Activate high speed (if supported)
+1
drivers/mmc/host/mxcmmc.c
··· 732 732 "failed to config DMA channel. Falling back to PIO\n"); 733 733 dma_release_channel(host->dma); 734 734 host->do_dma = 0; 735 + host->dma = NULL; 735 736 } 736 737 } 737 738
+5 -2
drivers/mmc/host/omap_hsmmc.c
··· 1010 1010 host->data->sg_len, 1011 1011 omap_hsmmc_get_dma_dir(host, host->data)); 1012 1012 omap_free_dma(dma_ch); 1013 + host->data->host_cookie = 0; 1013 1014 } 1014 1015 host->data = NULL; 1015 1016 } ··· 1576 1575 struct mmc_data *data = mrq->data; 1577 1576 1578 1577 if (host->use_dma) { 1579 - dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, 1580 - omap_hsmmc_get_dma_dir(host, data)); 1578 + if (data->host_cookie) 1579 + dma_unmap_sg(mmc_dev(host->mmc), data->sg, 1580 + data->sg_len, 1581 + omap_hsmmc_get_dma_dir(host, data)); 1581 1582 data->host_cookie = 0; 1582 1583 } 1583 1584 }
+1
drivers/mmc/host/sdhci-cns3xxx.c
··· 15 15 #include <linux/delay.h> 16 16 #include <linux/device.h> 17 17 #include <linux/mmc/host.h> 18 + #include <linux/module.h> 18 19 #include <mach/cns3xxx.h> 19 20 #include "sdhci-pltfm.h" 20 21
-2
drivers/mmc/host/sdhci-s3c.c
··· 644 644 static struct platform_driver sdhci_s3c_driver = { 645 645 .probe = sdhci_s3c_probe, 646 646 .remove = __devexit_p(sdhci_s3c_remove), 647 - .suspend = sdhci_s3c_suspend, 648 - .resume = sdhci_s3c_resume, 649 647 .driver = { 650 648 .owner = THIS_MODULE, 651 649 .name = "s3c-sdhci",
+1 -1
drivers/mmc/host/sh_mmcif.c
··· 908 908 if (host->power) { 909 909 pm_runtime_put(&host->pd->dev); 910 910 host->power = false; 911 - if (p->down_pwr) 911 + if (p->down_pwr && ios->power_mode == MMC_POWER_OFF) 912 912 p->down_pwr(host->pd); 913 913 } 914 914 host->state = STATE_IDLE;
+1 -1
drivers/mmc/host/tmio_mmc_pio.c
··· 798 798 /* start bus clock */ 799 799 tmio_mmc_clk_start(host); 800 800 } else if (ios->power_mode != MMC_POWER_UP) { 801 - if (host->set_pwr) 801 + if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) 802 802 host->set_pwr(host->pdev, 0); 803 803 if ((pdata->flags & TMIO_MMC_HAS_COLD_CD) && 804 804 pdata->power) {
+6
include/linux/mmc/card.h
··· 218 218 #define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */ 219 219 #define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */ 220 220 #define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8) /* Avoid sending 512 bytes in */ 221 + #define MMC_QUIRK_LONG_READ_TIME (1<<9) /* Data read time > CSD says */ 221 222 /* byte mode */ 222 223 unsigned int poweroff_notify_state; /* eMMC4.5 notify feature */ 223 224 #define MMC_NO_POWER_NOTIFICATION 0 ··· 432 431 static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c) 433 432 { 434 433 return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512; 434 + } 435 + 436 + static inline int mmc_card_long_read_time(const struct mmc_card *c) 437 + { 438 + return c->quirks & MMC_QUIRK_LONG_READ_TIME; 435 439 } 436 440 437 441 #define mmc_card_name(c) ((c)->cid.prod_name)