mmc: mmcblk: Add support for deferred SD bus resume
authorSan Mehat <san@google.com>
Thu, 30 Jul 2009 15:21:19 +0000 (08:21 -0700)
committerColin Cross <ccross@android.com>
Tue, 14 Jun 2011 16:08:52 +0000 (09:08 -0700)
Signed-off-by: San Mehat <san@google.com>
mmc: card: Add MMC_BLOCK_DEFERRED_RESUME option to Kconfig

Signed-off-by: San Mehat <san@google.com>
drivers/mmc/card/Kconfig
drivers/mmc/card/block.c
drivers/mmc/core/core.c

index 3b1f783bf924fccc2168aea37b9a1056d5095dd6..ebb4afe6c70242ce2bd48ef6db101df5dd284d40 100644 (file)
@@ -50,6 +50,15 @@ config MMC_BLOCK_BOUNCE
 
          If unsure, say Y here.
 
+config MMC_BLOCK_DEFERRED_RESUME
+       bool "Deferr MMC layer resume until I/O is requested"
+       depends on MMC_BLOCK
+       default n
+       help
+         Say Y here to enable deferred MMC resume until I/O
+         is requested. This will reduce overall resume latency and
+         save power when theres an SD card inserted but not being used.
+
 config SDIO_UART
        tristate "SDIO UART/GPS class support"
        help
index 71da5641e258e041cb9b72439d3d18eac9d9baa9..cda668ccf75755663dfa66b6dee09a3306119430 100644 (file)
@@ -939,12 +939,22 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *req)
        return 0;
 }
 
+static int
+mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card);
+
 static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 {
        int ret;
        struct mmc_blk_data *md = mq->data;
        struct mmc_card *card = md->queue.card;
 
+#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
+       if (mmc_bus_needs_resume(card->host)) {
+               mmc_resume_bus(card->host);
+               mmc_blk_set_blksize(md, card);
+       }
+#endif
+
        mmc_claim_host(card->host);
        ret = mmc_blk_part_switch(card, md);
        if (ret) {
@@ -1277,6 +1287,9 @@ static int mmc_blk_probe(struct mmc_card *card)
        mmc_set_drvdata(card, md);
        mmc_fixup_device(card, blk_fixups);
 
+#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
+       mmc_set_bus_resume_policy(card->host, 1);
+#endif
        if (mmc_add_disk(md))
                goto out;
 
@@ -1299,6 +1312,9 @@ static void mmc_blk_remove(struct mmc_card *card)
        mmc_blk_remove_parts(card, md);
        mmc_blk_remove_req(md);
        mmc_set_drvdata(card, NULL);
+#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
+       mmc_set_bus_resume_policy(card->host, 0);
+#endif
 }
 
 #ifdef CONFIG_PM
@@ -1322,7 +1338,9 @@ static int mmc_blk_resume(struct mmc_card *card)
        struct mmc_blk_data *md = mmc_get_drvdata(card);
 
        if (md) {
+#ifndef CONFIG_MMC_BLOCK_DEFERRED_RESUME
                mmc_blk_set_blksize(md, card);
+#endif
 
                /*
                 * Resume involves the card going into idle state,
index 14242c5e697c1116b1ebb73ea316b39fa4d3c166..3d9b0e16b4a4a7762699dd5cc181fc34304b6ec6 100644 (file)
@@ -1610,6 +1610,12 @@ void mmc_rescan(struct work_struct *work)
            && !(host->caps & MMC_CAP_NONREMOVABLE))
                host->bus_ops->detect(host);
 
+       /* If the card was removed the bus will be marked
+        * as dead - extend the wakelock so userspace
+        * can respond */
+       if (host->bus_dead)
+               extend_wakelock = 1;
+
        /*
         * Let mmc_bus_put() free the bus/bus_ops if we've found that
         * the card is no longer present.