Skip to contentSkip to conversation

mmc: core: hs200 fixes

PATCH In review Subhash Jadavani 3 participants 3 messages Mar 6, 2012 – Mar 9, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mmc: core: hs200 fixes

This patch fixes following issues when HS200 is enabled:

1. If executing_tuning() host ops is called without mmc_host_clk_hold(), card clocks might get turned off (if MMC_CLK_GATING is enabled) while execute_tuning() is in progress. So this patch makes sure that execute_tuning() is called with mmc_host_clk_hold().

2. If host timing mode is set to HS200 mode, there should not be any communication with the card until execute_tuning() is completed. But there is a chance that CMD6 might be sent to enable set HPI_EN (of HPI_MGMT field in EXT_CSD) before execute_tuning() is called. So this patch moves this operation after execute_tuning() is completed.

---
 drivers/mmc/core/mmc.c |   38 +++++++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 17 deletions(-)
drivers/mmc/core/mmc.c +21 -17
index a480663..d36d2c4 100644
@@ -1030,22 +1030,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	}
 
 	/*
-	 * Enable HPI feature (if supported)
-	 */
-	if (card->ext_csd.hpi) {
-		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-			EXT_CSD_HPI_MGMT, 1, 0);
-		if (err && err != -EBADMSG)
-			goto free_card;
-		if (err) {
-			pr_warning("%s: Enabling HPI failed\n",
-				   mmc_hostname(card->host));
-			err = 0;
-		} else
-			card->ext_csd.hpi_en = 1;
-	}
-
-	/*
 	 * Compute bus speed.
 	 */
 	max_dtr = (unsigned int)-1;
@@ -1094,9 +1078,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 		 * 4. execute tuning for HS200
 		 */
 		if ((host->caps2 & MMC_CAP2_HS200) &&
-		    card->host->ops->execute_tuning)
+		    card->host->ops->execute_tuning) {
+			mmc_host_clk_hold(card->host);
 			err = card->host->ops->execute_tuning(card->host,
 				MMC_SEND_TUNING_BLOCK_HS200);
+			mmc_host_clk_release(card->host);
+		}
 		if (err) {
 			pr_warning("%s: tuning execution failed\n",
 				   mmc_hostname(card->host));
@@ -1216,6 +1203,23 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	}
 
 	/*
+	 * Enable HPI feature (if supported)
+	 */
+	if (card->ext_csd.hpi) {
+		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+				EXT_CSD_HPI_MGMT, 1,
+				card->ext_csd.generic_cmd6_time);
+		if (err && err != -EBADMSG)
+			goto free_card;
+		if (err) {
+			pr_warning("%s: Enabling HPI failed\n",
+				   mmc_hostname(card->host));
+			err = 0;
+		} else
+			card->ext_csd.hpi_en = 1;
+	}
+
+	/*
 	 * If cache size is higher than 0, this indicates
 	 * the existence of cache and it can be turned on.
 	 */
Signature · 5 lines
1.7.1.1

--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Reviewed-by on v2 1/1
#1 lore raw
Quoted 73 lines · Subhash Jadavani

This patch fixes following issues when HS200 is enabled:

1. If executing_tuning() host ops is called without mmc_host_clk_hold(), card clocks might get turned off (if MMC_CLK_GATING is enabled) while execute_tuning() is in progress. So this patch makes sure that execute_tuning() is called with mmc_host_clk_hold().

2. If host timing mode is set to HS200 mode, there should not be any communication with the card until execute_tuning() is completed. But there is a chance that CMD6 might be sent to enable set HPI_EN (of HPI_MGMT field in EXT_CSD) before execute_tuning() is called. So this patch moves this operation after execute_tuning() is completed.

---
 drivers/mmc/core/mmc.c |   38 +++++++++++++++++++++-----------------

 1 files changed, 21 insertions(+), 17 deletions(-)
drivers/mmc/core/mmc.c +0 -16
index a480663..d36d2c4 100644
@@ -1030,22 +1030,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        }
 
        /*
-        * Enable HPI feature (if supported)
-        */
-       if (card->ext_csd.hpi) {
-               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                       EXT_CSD_HPI_MGMT, 1, 0);
-               if (err && err != -EBADMSG)
-                       goto free_card;
-               if (err) {
-                       pr_warning("%s: Enabling HPI failed\n",
-                                  mmc_hostname(card->host));
-                       err = 0;
-               } else
-                       card->ext_csd.hpi_en = 1;
-       }
-
-       /*
         * Compute bus speed.
         */
        max_dtr = (unsigned int)-1;
@@ -1094,9 +1078,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                 * 4. execute tuning for HS200
                 */

               if ((host->caps2 & MMC_CAP2_HS200) &&
-                   card->host->ops->execute_tuning)
+                   card->host->ops->execute_tuning) {
+                       mmc_host_clk_hold(card->host);
                       err = card->host->ops->execute_tuning(card->host, MMC_SEND_TUNING_BLOCK_HS200);
+                       mmc_host_clk_release(card->host);
+               }
               if (err) {
                       pr_warning("%s: tuning execution failed\n", mmc_hostname(card->host));

drivers/mmc/core/mmc.c +10 -0
@@ -1216,6 +1203,23 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
        }
 
        /*
+        * Enable HPI feature (if supported)
+        */
+       if (card->ext_csd.hpi) {
+               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+                               EXT_CSD_HPI_MGMT, 1,
+                               card->ext_csd.generic_cmd6_time);
+               if (err && err != -EBADMSG)
+                       goto free_card;
+               if (err) {
+                       pr_warning("%s: Enabling HPI failed\n",

drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host *host, u32 ocr, · line 1225

Quoted 10 lines
drivers/mmc/core/mmc.c +7 -0
+                                  mmc_hostname(card->host));
+                       err = 0;
+               } else
+                       card->ext_csd.hpi_en = 1;
+       }
+
+       /*
         * If cache size is higher than 0, this indicates
         * the existence of cache and it can be turned on.
         */
Reviewed-by [email protected]
Quoted 6 lines

--
1.7.1.1

--
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

#2 lore raw

Hi,

Quoted 81 lines · Girish K S
Quoted 80 lines · Subhash Jadavani

This patch fixes following issues when HS200 is enabled:

1. If executing_tuning() host ops is called without mmc_host_clk_hold(), card clocks might get turned off (if MMC_CLK_GATING is enabled) while execute_tuning() is in progress. So this patch makes sure that execute_tuning() is called with mmc_host_clk_hold().

2. If host timing mode is set to HS200 mode, there should not be any communication with the card until execute_tuning() is completed. But there is a chance that CMD6 might be sent to enable set HPI_EN (of HPI_MGMT field in EXT_CSD) before execute_tuning() is called. So this patch moves this operation after execute_tuning() is completed.

---
 drivers/mmc/core/mmc.c |   38 +++++++++++++++++++++-----------------

 1 files changed, 21 insertions(+), 17 deletions(-)
drivers/mmc/core/mmc.c +0 -16
index a480663..d36d2c4 100644
@@ -1030,22 +1030,6 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,
        }
 
        /*
-        * Enable HPI feature (if supported)
-        */
-       if (card->ext_csd.hpi) {
-               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                       EXT_CSD_HPI_MGMT, 1, 0);
-               if (err && err != -EBADMSG)
-                       goto free_card;
-               if (err) {
-                       pr_warning("%s: Enabling HPI failed\n",
-                                  mmc_hostname(card->host));
-                       err = 0;
-               } else
-                       card->ext_csd.hpi_en = 1;
-       }
-
-       /*
         * Compute bus speed.
         */

       max_dtr = (unsigned int)-1;

drivers/mmc/core/mmc.c +0 -0
@@ -1094,9 +1078,12 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,
                 * 4. execute tuning for HS200
                 */

               if ((host->caps2 & MMC_CAP2_HS200) &&
-                   card->host->ops->execute_tuning)
+                   card->host->ops->execute_tuning) {
+                       mmc_host_clk_hold(card->host);
                       err = card->host->ops->execute_tuning(card->host, MMC_SEND_TUNING_BLOCK_HS200);
+                       mmc_host_clk_release(card->host);
+               }
               if (err) {
                       pr_warning("%s: tuning execution failed\n", mmc_hostname(card->host));

drivers/mmc/core/mmc.c +14 -0
@@ -1216,6 +1203,23 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,
        }
 
        /*
+        * Enable HPI feature (if supported)
+        */
+       if (card->ext_csd.hpi) {
+               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+                               EXT_CSD_HPI_MGMT, 1,
+                               card->ext_csd.generic_cmd6_time);
+               if (err && err != -EBADMSG)
+                       goto free_card;
+               if (err) {
+                       pr_warning("%s: Enabling HPI failed\n",
+                                  mmc_hostname(card->host));
+                       err = 0;
+               } else
+                       card->ext_csd.hpi_en = 1;
Quoted 8 lines
Quoted 6 lines
drivers/mmc/core/mmc.c +3 -0
+       }
+
+       /*
         * If cache size is higher than 0, this indicates
         * the existence of cache and it can be turned on.

        */

Reviewed-by [email protected]

Thanks, pushed to mmc-next for 3.4.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child