mmc: use max_discard_to for SD write timeout
authorChuanxiao Dong <chuanxiao.dong@intel.com>
Fri, 17 Feb 2012 06:40:25 +0000 (14:40 +0800)
committerbuildbot <buildbot@intel.com>
Mon, 20 Feb 2012 14:46:15 +0000 (06:46 -0800)
BZ: 24030

max_discard_to is the max timeout value allowed by host. Use
this value can stop kernel printing too large timeout warning.

Change-Id: Iaa0828475849f466f45ef55d3d4c8ae7f220b073
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Reviewed-on: http://android.intel.com:8080/35692
Reviewed-by: Gross, Mark <mark.gross@intel.com>
Tested-by: Sun, Jianhua <jianhua.sun@intel.com>
Reviewed-by: Tang, Richard <richard.tang@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/mmc/core/core.c
drivers/mmc/host/sdhci.c

index af4b5d9..5fe5c47 100644 (file)
@@ -598,7 +598,7 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
                        timeout_us += data->timeout_clks * 1000 /
                                (mmc_host_clk_rate(card->host) / 1000);
 
-               if (data->flags & MMC_DATA_WRITE)
+               if (data->flags & MMC_DATA_WRITE) {
                        /*
                         * The limit is really 250 ms, but that is
                         * insufficient for some crappy cards.
@@ -613,9 +613,19 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
                         * interrupt.
                         *
                         * Increase this value to be 3s.
+                        *
+                        * If host has max_discard_to, use max_discard_to as
+                        * timeout value. Use max_discard_to -1 to make sure
+                        * the write timeout value won't large than the max
                         */
-                       limit_us = 3000000;
-               else
+                       if (card->host->max_discard_to) {
+                               limit_us =
+                                       (card->host->max_discard_to - 1) * 1000;
+                               if (limit_us > 3000000)
+                                       limit_us = 3000000;
+                       } else
+                               limit_us = 3000000;
+               } else
                        limit_us = 100000;
 
                /*
index c6930a5..39ed356 100644 (file)
@@ -707,8 +707,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
        }
 
        if (count >= 0xF) {
-               printk(KERN_WARNING "%s: Too large timeout requested for CMD%d!\n",
-                      mmc_hostname(host->mmc), cmd->opcode);
+               if (target_timeout > (host->mmc->max_discard_to * 1000))
+                       pr_warn("%s: Too large timeout requested for CMD%d!\n",
+                              mmc_hostname(host->mmc), cmd->opcode);
                count = 0xE;
        }