History

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

Linus Torvalds committed 14 years ago

Commit 71fe5cc2 parents dc47ce9 49df78010 files · +95 −44Browse files

Unified · Split

10 files
  1. drivers/mmc/card/block.c +8 −0
  2. drivers/mmc/core/core.c +64 −34
  3. drivers/mmc/core/mmc.c +8 −4
  4. drivers/mmc/host/mxcmmc.c +1 −0
  5. drivers/mmc/host/omap_hsmmc.c +5 −2
  6. drivers/mmc/host/sdhci-cns3xxx.c +1 −0
  7. drivers/mmc/host/sdhci-s3c.c +0 −2
  8. drivers/mmc/host/sh_mmcif.c +1 −1
  9. drivers/mmc/host/tmio_mmc_pio.c +1 −1
  10. include/linux/mmc/card.h +6 −0
drivers/mmc/card/block.c+8−0
@@ -1606,6 +1606,14 @@ static const struct mmc_fixup blk_fixups[] = · 1605 unmodified lines
16061606 MMC_QUIRK_BLK_NO_CMD23),
16071607 MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc,
16081608 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+
16091617 END_FIXUP
16101618 };
16111619
drivers/mmc/core/core.c+64−34
@@ -529,6 +529,18 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) · 528 unmodified lines
529529 data->timeout_clks = 0;
530530 }
531531 }
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+
532544 /*
533545 * Some cards need very high timeouts if driven in SPI mode.
534546 * The worst observed timeout was 900ms after writing a
@@ -1213,6 +1225,46 @@ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) · 678 unmodified lines
12131225 mmc_host_clk_release(host);
12141226 }
12151227
1228+static void mmc_poweroff_notify(struct mmc_host *host)
1229+{
1230+ struct mmc_card *card;
1231+ unsigned int timeout;
1232+ unsigned int notify_type = EXT_CSD_NO_POWER_NOTIFICATION;
1233+ int err = 0;
1234+
1235+ card = host->card;
1236+
1237+ /*
1238+ * Send power notify command only if card
1239+ * is mmc and notify state is powered ON
1240+ */
1241+ if (card && mmc_card_mmc(card) &&
1242+ (card->poweroff_notify_state == MMC_POWERED_ON)) {
1243+
1244+ if (host->power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) {
1245+ notify_type = EXT_CSD_POWER_OFF_SHORT;
1246+ timeout = card->ext_csd.generic_cmd6_time;
1247+ card->poweroff_notify_state = MMC_POWEROFF_SHORT;
1248+ } else {
1249+ notify_type = EXT_CSD_POWER_OFF_LONG;
1250+ timeout = card->ext_csd.power_off_longtime;
1251+ card->poweroff_notify_state = MMC_POWEROFF_LONG;
1252+ }
1253+
1254+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1255+ EXT_CSD_POWER_OFF_NOTIFICATION,
1256+ notify_type, timeout);
1257+
1258+ if (err && err != -EBADMSG)
1259+ pr_err("Device failed to respond within %d poweroff "
1260+ "time. Forcefully powering down the device\n",
1261+ timeout);
1262+
1263+ /* Set the card state to no notification after the poweroff */
1264+ card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION;
1265+ }
1266+}
1267+
12161268 /*
12171269 * Apply power to the MMC stack. This is a two-stage process.
12181270 * First, we enable power to the card without the clock running.
@@ -1269,42 +1321,12 @@ static void mmc_power_up(struct mmc_host *host) · 50 unmodified lines
12691321
12701322 void mmc_power_off(struct mmc_host *host)
12711323 {
1272− struct mmc_card *card;
1273− unsigned int notify_type;
1274− unsigned int timeout;
1275− int err;
1276−
12771324 mmc_host_clk_hold(host);
12781325
1279− card = host->card;
12801326 host->ios.clock = 0;
12811327 host->ios.vdd = 0;
12821328
1283− if (card && mmc_card_mmc(card) &&
1284− (card->poweroff_notify_state == MMC_POWERED_ON)) {
1285−
1286− if (host->power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) {
1287− notify_type = EXT_CSD_POWER_OFF_SHORT;
1288− timeout = card->ext_csd.generic_cmd6_time;
1289− card->poweroff_notify_state = MMC_POWEROFF_SHORT;
1290− } else {
1291− notify_type = EXT_CSD_POWER_OFF_LONG;
1292− timeout = card->ext_csd.power_off_longtime;
1293− card->poweroff_notify_state = MMC_POWEROFF_LONG;
1294− }
1295−
1296− err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1297− EXT_CSD_POWER_OFF_NOTIFICATION,
1298− notify_type, timeout);
1299−
1300− if (err && err != -EBADMSG)
1301− pr_err("Device failed to respond within %d poweroff "
1302− "time. Forcefully powering down the device\n",
1303− timeout);
1304−
1305− /* Set the card state to no notification after the poweroff */
1306− card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION;
1307− }
1329+ mmc_poweroff_notify(host);
13081330
13091331 /*
13101332 * Reset ocr mask to be the highest possible voltage supported for
@@ -2196,7 +2218,7 @@ int mmc_card_sleep(struct mmc_host *host) · 885 unmodified lines
21962218
21972219 mmc_bus_get(host);
21982220
2199− if (host->bus_ops && !host->bus_dead && host->bus_ops->awake)
2221+ if (host->bus_ops && !host->bus_dead && host->bus_ops->sleep)
22002222 err = host->bus_ops->sleep(host);
22012223
22022224 mmc_bus_put(host);
@@ -2302,8 +2324,17 @@ int mmc_suspend_host(struct mmc_host *host) · 99 unmodified lines
23022324 * pre-claim the host.
23032325 */
23042326 if (mmc_try_claim_host(host)) {
2305− if (host->bus_ops->suspend)
2327+ if (host->bus_ops->suspend) {
2328+ /*
2329+ * For eMMC 4.5 device send notify command
2330+ * before sleep, because in sleep state eMMC 4.5
2331+ * devices respond to only RESET and AWAKE cmd
2332+ */
2333+ mmc_poweroff_notify(host);
23062334 err = host->bus_ops->suspend(host);
2335+ }
2336+ mmc_do_release_host(host);
2337+
23072338 if (err == -ENOSYS || !host->bus_ops->resume) {
23082339 /*
23092340 * We simply "remove" the card in this case.
@@ -2318,7 +2349,6 @@ int mmc_suspend_host(struct mmc_host *host) · 8 unmodified lines
23182349 host->pm_flags = 0;
23192350 err = 0;
23202351 }
2321− mmc_do_release_host(host);
23222352 } else {
23232353 err = -EBUSY;
23242354 }
drivers/mmc/core/mmc.c+8−4
@@ -876,17 +876,21 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, · 875 unmodified lines
876876 * set the notification byte in the ext_csd register of device
877877 */
878878 if ((host->caps2 & MMC_CAP2_POWEROFF_NOTIFY) &&
879− (card->poweroff_notify_state == MMC_NO_POWER_NOTIFICATION)) {
879+ (card->ext_csd.rev >= 6)) {
880880 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
881881 EXT_CSD_POWER_OFF_NOTIFICATION,
882882 EXT_CSD_POWER_ON,
883883 card->ext_csd.generic_cmd6_time);
884884 if (err && err != -EBADMSG)
885885 goto free_card;
886− }
887886
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+ }
890894
891895 /*
892896 * Activate high speed (if supported)
drivers/mmc/host/mxcmmc.c+1−0
@@ -732,6 +732,7 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · 731 unmodified lines
732732 "failed to config DMA channel. Falling back to PIO\n");
733733 dma_release_channel(host->dma);
734734 host->do_dma = 0;
735+ host->dma = NULL;
735736 }
736737 }
737738
drivers/mmc/host/omap_hsmmc.c+5−2
@@ -1010,6 +1010,7 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) · 1009 unmodified lines
10101010 host->data->sg_len,
10111011 omap_hsmmc_get_dma_dir(host, host->data));
10121012 omap_free_dma(dma_ch);
1013+ host->data->host_cookie = 0;
10131014 }
10141015 host->data = NULL;
10151016 }
@@ -1575,8 +1576,10 @@ static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, · 559 unmodified lines
15751576 struct mmc_data *data = mrq->data;
15761577
15771578 if (host->use_dma) {
1578− dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
1579− omap_hsmmc_get_dma_dir(host, data));
1579+ if (data->host_cookie)
1580+ dma_unmap_sg(mmc_dev(host->mmc), data->sg,
1581+ data->sg_len,
1582+ omap_hsmmc_get_dma_dir(host, data));
15801583 data->host_cookie = 0;
15811584 }
15821585 }
drivers/mmc/host/sdhci-cns3xxx.c+1−0
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/delay.h>
1616 #include <linux/device.h>
1717 #include <linux/mmc/host.h>
18+#include <linux/module.h>
1819 #include <mach/cns3xxx.h>
1920 #include "sdhci-pltfm.h"
2021
drivers/mmc/host/sdhci-s3c.c+0−2
@@ -644,8 +644,6 @@ static int sdhci_s3c_resume(struct platform_device *dev) · 643 unmodified lines
644644 static struct platform_driver sdhci_s3c_driver = {
645645 .probe = sdhci_s3c_probe,
646646 .remove = __devexit_p(sdhci_s3c_remove),
647− .suspend = sdhci_s3c_suspend,
648− .resume = sdhci_s3c_resume,
649647 .driver = {
650648 .owner = THIS_MODULE,
651649 .name = "s3c-sdhci",
drivers/mmc/host/sh_mmcif.c+1−1
@@ -908,7 +908,7 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · 907 unmodified lines
908908 if (host->power) {
909909 pm_runtime_put(&host->pd->dev);
910910 host->power = false;
911− if (p->down_pwr)
911+ if (p->down_pwr && ios->power_mode == MMC_POWER_OFF)
912912 p->down_pwr(host->pd);
913913 }
914914 host->state = STATE_IDLE;
drivers/mmc/host/tmio_mmc_pio.c+1−1
@@ -798,7 +798,7 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · 797 unmodified lines
798798 /* start bus clock */
799799 tmio_mmc_clk_start(host);
800800 } else if (ios->power_mode != MMC_POWER_UP) {
801− if (host->set_pwr)
801+ if (host->set_pwr && ios->power_mode == MMC_POWER_OFF)
802802 host->set_pwr(host->pdev, 0);
803803 if ((pdata->flags & TMIO_MMC_HAS_COLD_CD) &&
804804 pdata->power) {
include/linux/mmc/card.h+6−0
@@ -218,6 +218,7 @@ struct mmc_card { · 217 unmodified lines
218218 #define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
219219 #define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
220220 #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 */
221222 /* byte mode */
222223 unsigned int poweroff_notify_state; /* eMMC4.5 notify feature */
223224 #define MMC_NO_POWER_NOTIFICATION 0
@@ -433,6 +434,11 @@ static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c) · 209 unmodified lines
433434 return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512;
434435 }
435436
437+static inline int mmc_card_long_read_time(const struct mmc_card *c)
438+{
439+ return c->quirks & MMC_QUIRK_LONG_READ_TIME;
440+}
441+
436442 #define mmc_card_name(c) ((c)->cid.prod_name)
437443 #define mmc_card_id(c) (dev_name(&(c)->dev))
438444