Skip to contentSkip to conversation

mmc: core: fix power class selection

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

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

PATCH 1/1 mmc: core: fix power class selection

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class. If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

---
 drivers/mmc/core/mmc.c |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/mmc/core/mmc.c +17 -13
index 02914d6..54df5ad 100644
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card *card,
 		else if (host->ios.clock <= 200000000)
 			index = EXT_CSD_PWR_CL_200_195;
 		break;
+	case MMC_VDD_27_28:
+	case MMC_VDD_28_29:
+	case MMC_VDD_29_30:
+	case MMC_VDD_30_31:
+	case MMC_VDD_31_32:
 	case MMC_VDD_32_33:
 	case MMC_VDD_33_34:
 	case MMC_VDD_34_35:
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 		ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ?
 				EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4;
 		err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-		if (err) {
-			pr_err("%s: power class selection to bus width %d failed\n",
-				mmc_hostname(card->host), 1 << bus_width);
-			goto err;
-		}
+		if (err)
+			pr_warning("%s: power class selection to bus width %d"
+				   " failed\n", mmc_hostname(card->host),
+				   1 << bus_width);
 	}
 
 	/*
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 			err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
 						    ext_csd);
 			if (err)
-				pr_err("%s: power class selection to "
-				       "bus width %d failed\n",
-				       mmc_hostname(card->host),
-				       1 << bus_width);
+				pr_warning("%s: power class selection to "
+					   "bus width %d failed\n",
+					   mmc_hostname(card->host),
+					   1 << bus_width);
 
 			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 					 EXT_CSD_BUS_WIDTH,
@@ -1178,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 			err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
 						    ext_csd);
 			if (err)
-				pr_err("%s: power class selection to "
-				       "bus width %d ddr %d failed\n",
-				       mmc_hostname(card->host),
-				       1 << bus_width, ddr);
+				pr_warning("%s: power class selection to "
+					   "bus width %d ddr %d failed\n",
+					   mmc_hostname(card->host),
+					   1 << bus_width, ddr);
 
 			err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
 					 EXT_CSD_BUS_WIDTH,
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.
#1 lore raw
Quoted 71 lines · Subhash Jadavani

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class. If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

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

 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/mmc/core/mmc.c +5 -0
index 02914d6..54df5ad 100644
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card *card,
                else if (host->ios.clock <= 200000000)
                        index = EXT_CSD_PWR_CL_200_195;
                break;
+       case MMC_VDD_27_28:
+       case MMC_VDD_28_29:
+       case MMC_VDD_29_30:
+       case MMC_VDD_30_31:
+       case MMC_VDD_31_32:

       case MMC_VDD_32_33:
       case MMC_VDD_33_34:
       case MMC_VDD_34_35:

drivers/mmc/core/mmc.c +0 -0
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,

               ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-               if (err) {
-                       pr_err("%s: power class selection to bus width %d failed\n",
-                               mmc_hostname(card->host), 1 << bus_width);
-                       goto err;
-               }
+               if (err)
+                       pr_warning("%s: power class selection to bus width %d"
+                                  " failed\n", mmc_hostname(card->host),
+                                  1 << bus_width);
       }

       /*

drivers/mmc/core/mmc.c +4 -5
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                        err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to "
-                                      "bus width %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width);
+                               pr_warning("%s: power class selection to "
+                                          "bus width %d failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width);
 
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                         EXT_CSD_BUS_WIDTH,
@@ -1178,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                        err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to "

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

Quoted 10 lines
drivers/mmc/core/mmc.c +4 -3
-                                      "bus width %d ddr %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width, ddr);
+                               pr_warning("%s: power class selection to "
+                                          "bus width %d ddr %d failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width, ddr);
 
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                         EXT_CSD_BUS_WIDTH,

looks good to me
Acked By: Girish K S <[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.

Reviewed-by
#2 lore raw

2012/4/3 Girish K S <[email protected]>:

Quoted 15 lines · Subhash Jadavani
Quoted 14 lines

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class. If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

Quoted 3 lines
Quoted 1 line

looks good to me
Acked By:  Girish K S <[email protected]>

I double checked with specification. this patch make good sense.

Thanks

Quoted 10 lines
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.

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#3 lore raw

Hi,

Quoted 16 lines · Namjae Jeon

2012/4/3 Girish K S <[email protected]>:

Quoted 15 lines · Subhash Jadavani
Quoted 14 lines

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class. If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

looks good to me
Acked By:  Girish K S <[email protected]>

I double checked with specification. this patch make good sense.

Thanks, pushed to mmc-next for 3.4.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#4 lore raw
In reply to Subhash Jadavani
Quoted 7 lines · Subhash Jadavani

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Quoted 7 lines

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class. If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

Have you checked why mmc_select_powerclass returned error ? Today, in the mmc_select_powerclass, it is just setting the value of power class, which the eMMC expects. So, it should not fail.

Another point is that, today mmc_select_powerclass is assuming that host can support the maximum possible power classes and it does not check host controllers capability in driving higher current (mA). But I think in future we need to add this check for host controller ability and return error from mmc_select_powerclass so that mmc_init_card can choose the next speed mode. From that perspective, the approach to ignore the error return from mmc_select_powerclass looks wrong.

Quoted 77 lines

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

 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/mmc/core/mmc.c +5 -0
index 02914d6..54df5ad 100644
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card *card,
                else if (host->ios.clock <= 200000000)
                        index = EXT_CSD_PWR_CL_200_195;
                break;
+       case MMC_VDD_27_28:
+       case MMC_VDD_28_29:
+       case MMC_VDD_29_30:
+       case MMC_VDD_30_31:
+       case MMC_VDD_31_32:

       case MMC_VDD_32_33:
       case MMC_VDD_33_34:
       case MMC_VDD_34_35:

drivers/mmc/core/mmc.c +0 -0
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,

               ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? EXT_CSD_BUS_WIDTH_8 : EXT_CSD_BUS_WIDTH_4; err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-               if (err) {
-                       pr_err("%s: power class selection to bus width %d failed\n",
-                               mmc_hostname(card->host), 1 << bus_width);
-                       goto err;
-               }
+               if (err)
+                       pr_warning("%s: power class selection to bus width %d"
+                                  " failed\n", mmc_hostname(card->host),
+                                  1 << bus_width);
       }

       /*

drivers/mmc/core/mmc.c +8 -9
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                        err = mmc_select_powerclass(card, ext_csd_bits[idx][0],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to "
-                                      "bus width %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width);
+                               pr_warning("%s: power class selection to "
+                                          "bus width %d failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width);
 
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                         EXT_CSD_BUS_WIDTH,
@@ -1178,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                        err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to "
-                                      "bus width %d ddr %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width, ddr);
+                               pr_warning("%s: power class selection to "
+                                          "bus width %d ddr %d failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width, ddr);
 
                        err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                         EXT_CSD_BUS_WIDTH,
--

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. --
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 25 lines

-----Original Message-----
From: Saugata Das [mailto:[email protected]]
Sent: Tuesday, April 03, 2012 8:55 PM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/1] mmc: core: fix power class selection

Quoted 7 lines · Subhash Jadavani

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Quoted 6 lines

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class.
If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

Quoted 2 lines

Have you checked why mmc_select_powerclass returned error ? Today, in the mmc_select_powerclass, it is just setting the value of power class,

which

Quoted 5 lines

the eMMC expects. So, it should not fail.

Another point is that, today mmc_select_powerclass is assuming that host can support the maximum possible power classes and it does not check host controllers capability in driving higher current (mA). But I think in

future we

Quoted 2 lines

need to add this check for host controller ability and return error from mmc_select_powerclass so that mmc_init_card can choose the next speed

Agreed with this point.

Quoted 2 lines

mode. From that perspective, the approach to ignore the error return from mmc_select_powerclass looks wrong.

My patch was just intended to fix the issue existing power class implementation. As commit text says:
- don't consider 2.7v to 3.2v as invalid range
- We are already ignoring the error returned by
mmc_set_power_class() function for DS/HS/DDR cards. So this patch has extended that to HS200 cards.

So as far as this patch is concerned, I don't see anything wrong here.

As you have mentioned, currently we are not taking the host controller capability into account (as it doesn't exist as of now) so we should not see mmc_select_powerclass() fail any time.
But yes, next thing should be to take into account the host current sourcing capability before deciding which bus speed mode to choose. But that may be a big change and should be as separate patch. Girish had already posted one patch for this which needs to be extended to achieve this.

Regards,
Subhash

Quoted 32 lines
Quoted 32 lines

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

 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

02914d6..54df5ad 100644

drivers/mmc/core/mmc.c +5 -0
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card
 *card,
                else if (host->ios.clock <= 200000000)
                        index = EXT_CSD_PWR_CL_200_195;
                break;
+       case MMC_VDD_27_28:
+       case MMC_VDD_28_29:
+       case MMC_VDD_29_30:
+       case MMC_VDD_30_31:
+       case MMC_VDD_31_32:

       case MMC_VDD_32_33:
       case MMC_VDD_33_34:
       case MMC_VDD_34_35:

drivers/mmc/core/mmc.c +0 -0
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,

               ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? EXT_CSD_BUS_WIDTH_8 :
EXT_CSD_BUS_WIDTH_4;
               err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-               if (err) {

Quoted 8 lines
Quoted 8 lines

-                       pr_err("%s: power class selection to bus width %d failed\n",
-                               mmc_hostname(card->host), 1 << bus_width);
-                       goto err;
-               }
+               if (err)
+                       pr_warning("%s: power class selection to bus

width %d"

Quoted 5 lines
Quoted 5 lines

+                                  " failed\n",
+ mmc_hostname(card->host),
+                                  1 << bus_width); }

Quoted 12 lines

drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host · line 1156

Quoted 12 lines

       /*

drivers/mmc/core/mmc.c +1 -4
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,
                        err = mmc_select_powerclass(card,
 ext_csd_bits[idx][0],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to "
-                                      "bus width %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width);
+                               pr_warning("%s: power class selection to

"

Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/mmc.c +3 -0
+                                          "bus width %d failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width);
 
Quoted 12 lines
Quoted 4 lines

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, @@ -1178,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, err = mmc_select_powerclass(card,

Quoted 8 lines

ext_csd_bits[idx][1],
                                                   ext_csd); if (err)
-                               pr_err("%s: power class selection to "
-                                      "bus width %d ddr %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width, ddr);
+                               pr_warning("%s: power class selection to

"

Quoted 19 lines
Quoted 5 lines

+                                          "bus width %d ddr %d
+ failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width, ddr);

Quoted 8 lines

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, --
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.

Quoted 3 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More

majordomo

Quoted 1 line

info at  http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 49 lines · Subhash Jadavani
Quoted 25 lines

-----Original Message-----
From: Saugata Das [mailto:[email protected]]
Sent: Tuesday, April 03, 2012 8:55 PM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/1] mmc: core: fix power class selection

Quoted 7 lines · Subhash Jadavani

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Quoted 6 lines

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class.
If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

Quoted 2 lines

Have you checked why mmc_select_powerclass returned error ? Today, in the mmc_select_powerclass, it is just setting the value of power class,

which

Quoted 5 lines

the eMMC expects. So, it should not fail.

Another point is that, today mmc_select_powerclass is assuming that host can support the maximum possible power classes and it does not check host controllers capability in driving higher current (mA). But I think in

future we

Quoted 2 lines

need to add this check for host controller ability and return error from mmc_select_powerclass so that mmc_init_card can choose the next speed

Agreed with this point.

Quoted 2 lines

mode. From that perspective, the approach to ignore the error return from mmc_select_powerclass looks wrong.

My patch was just intended to fix the issue existing power class implementation. As commit text says:
       - don't consider 2.7v to 3.2v as invalid range
       - We are already ignoring the error returned by mmc_set_power_class() function for DS/HS/DDR cards. So this patch has extended that to HS200 cards.

Quoted 5 lines

So as far as this patch is concerned, I don't see anything wrong here.

As you have mentioned, currently we are not taking the host controller capability into account (as it doesn't exist as of now) so we should not see mmc_select_powerclass() fail any time.

This is actually the main concern. The fail of mmc_select_powerclass is something to be checked and not ignored since it should not fail under the current implementation.

Quoted 104 lines

But yes, next thing should be to take into account the host current sourcing capability before deciding which bus speed mode to choose. But that may be a big change and should be as separate patch. Girish had already posted one patch for this which needs to be extended to achieve this.

Regards,
Subhash

Quoted 32 lines
Quoted 32 lines

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

 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

02914d6..54df5ad 100644

drivers/mmc/core/mmc.c +5 -0
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct mmc_card
 *card,
                else if (host->ios.clock <= 200000000)
                        index = EXT_CSD_PWR_CL_200_195;
                break;
+       case MMC_VDD_27_28:
+       case MMC_VDD_28_29:
+       case MMC_VDD_29_30:
+       case MMC_VDD_30_31:
+       case MMC_VDD_31_32:

       case MMC_VDD_32_33:
       case MMC_VDD_33_34:
       case MMC_VDD_34_35:

drivers/mmc/core/mmc.c +0 -0
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,

               ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? EXT_CSD_BUS_WIDTH_8 :
EXT_CSD_BUS_WIDTH_4;
               err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-               if (err) {

Quoted 8 lines
Quoted 8 lines

-                       pr_err("%s: power class selection to bus width %d failed\n",
-                               mmc_hostname(card->host), 1 << bus_width);
-                       goto err;
-               }
+               if (err)
+                       pr_warning("%s: power class selection to bus

width %d"

Quoted 5 lines
Quoted 5 lines

+                                  " failed\n",
+ mmc_hostname(card->host),
+                                  1 << bus_width); }

Quoted 12 lines

drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host · line 1156

Quoted 12 lines

       /*

drivers/mmc/core/mmc.c +1 -4
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,
                        err = mmc_select_powerclass(card,
 ext_csd_bits[idx][0],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to "
-                                      "bus width %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width);
+                               pr_warning("%s: power class selection to

"

Quoted 4 lines
Quoted 4 lines
drivers/mmc/core/mmc.c +3 -0
+                                          "bus width %d failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width);
 
Quoted 12 lines
Quoted 4 lines

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, @@ -1178,10 +1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, err = mmc_select_powerclass(card,

Quoted 8 lines

ext_csd_bits[idx][1],
                                                   ext_csd); if (err)
-                               pr_err("%s: power class selection to "
-                                      "bus width %d ddr %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width, ddr);
+                               pr_warning("%s: power class selection to

"

Quoted 19 lines
Quoted 5 lines

+                                          "bus width %d ddr %d
+ failed\n",
+                                          mmc_hostname(card->host),
+                                          1 << bus_width, ddr);

Quoted 8 lines

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, --
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.

Quoted 3 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More

majordomo

Quoted 1 line

info at  http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 68 lines

-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Saugata Das
Sent: Tuesday, April 03, 2012 9:48 PM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/1] mmc: core: fix power class selection

Quoted 11 lines · Subhash Jadavani
Quoted 11 lines

-----Original Message-----
From: Saugata Das [mailto:[email protected]]
Sent: Tuesday, April 03, 2012 8:55 PM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/1] mmc: core: fix power class selection

On 3 April 2012 12:25, Subhash Jadavani <[email protected]>

Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class.
If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

Have you checked why mmc_select_powerclass returned error ? Today,

in

Quoted 28 lines
Quoted 2 lines

the mmc_select_powerclass, it is just setting the value of power class,

which

Quoted 6 lines

the eMMC expects. So, it should not fail.

Another point is that, today mmc_select_powerclass is assuming that host can support the maximum possible power classes and it does not check host controllers capability in driving higher current (mA). But I think in

future we

Quoted 3 lines

need to add this check for host controller ability and return error from mmc_select_powerclass so that mmc_init_card can choose the next speed

Agreed with this point.

Quoted 2 lines

mode. From that perspective, the approach to ignore the error return from mmc_select_powerclass looks wrong.

My patch was just intended to fix the issue existing power class implementation. As commit text says:
       - don't consider 2.7v to 3.2v as invalid range
       - We are already ignoring the error returned by mmc_set_power_class() function for DS/HS/DDR cards. So this patch has extended that to HS200 cards.

So as far as this patch is concerned, I don't see anything wrong here.

Quoted 8 lines
Quoted 4 lines

As you have mentioned, currently we are not taking the host controller capability into account (as it doesn't exist as of now) so we should not see
mmc_select_powerclass() fail any time.

This is actually the main concern. The fail of mmc_select_powerclass is something to be checked and not ignored since it should not fail under the current implementation.

Yes, this makes sense. With current implementation, mmc_select_powerclass() should never really fail which means failure should be treated as fatal and we should really skip the card initialization.
This patch is already pushed to mmc-next. So I will post another patch (by next week as I will be on vacation in this week) to skip the card initialization if mmc_select_powerclass fails.

Is this ok?

Regards,
Subhash

Quoted 58 lines
Quoted 6 lines

But yes, next thing should be to take into account the host current sourcing capability before deciding which bus speed mode to choose. But that may be a big change and should be as separate patch. Girish had already posted one patch for this which needs to be extended to

achieve this.

Quoted 51 lines

Regards,
Subhash

Quoted 33 lines
Quoted 33 lines

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

 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

02914d6..54df5ad 100644

drivers/mmc/core/mmc.c +5 -0
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct
 mmc_card *card,
                else if (host->ios.clock <= 200000000)
                        index = EXT_CSD_PWR_CL_200_195;
                break;
+       case MMC_VDD_27_28:
+       case MMC_VDD_28_29:
+       case MMC_VDD_29_30:
+       case MMC_VDD_30_31:
+       case MMC_VDD_31_32:

       case MMC_VDD_32_33:
       case MMC_VDD_33_34:
       case MMC_VDD_34_35:

drivers/mmc/core/mmc.c +0 -0
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,

               ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? EXT_CSD_BUS_WIDTH_8 :
EXT_CSD_BUS_WIDTH_4;
               err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-               if (err) {
-                       pr_err("%s: power class selection to bus

Quoted 8 lines
Quoted 8 lines

width %d failed\n",
-                               mmc_hostname(card->host), 1 << bus_width);
-                       goto err;
-               }
+               if (err)
+                       pr_warning("%s: power class selection to
+ bus

width %d"

Quoted 5 lines
Quoted 5 lines

+                                  " failed\n",
+ mmc_hostname(card->host),
+                                  1 << bus_width); }

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host · line 1152

Quoted 8 lines

       /*

drivers/mmc/core/mmc.c +0 -1
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,
                        err = mmc_select_powerclass(card,
 ext_csd_bits[idx][0],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to

"

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

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

Quoted 5 lines
drivers/mmc/core/mmc.c +2 -3
-                                      "bus width %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width);
+                               pr_warning("%s: power class
+ selection to

"

Quoted 5 lines
Quoted 5 lines
drivers/mmc/core/mmc.c +4 -0
+                                          "bus width %d failed\n",
+
+ mmc_hostname(card->host),
+                                          1 << bus_width);
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                        EXT_CSD_BUS_WIDTH, @@ -1178,10
+1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 +ocr,
                       err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
                                                   ext_csd); if (err)
-                               pr_err("%s: power class selection to

"

Quoted 23 lines
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines

-                                      "bus width %d ddr %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width, ddr);
+                               pr_warning("%s: power class
+ selection to

"

Quoted 16 lines
Quoted 12 lines

+                                          "bus width %d ddr %d
+ failed\n",
+
+ mmc_hostname(card->host),
+                                          1 << bus_width, ddr);

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                        EXT_CSD_BUS_WIDTH, --
1.7.1.1

Quoted 3 lines

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

Forum.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More

majordomo

Quoted 1 line

info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in

the

Quoted 2 lines

body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

#8 lore raw

Hi,

Quoted 8 lines

Yes, this makes sense. With current implementation, mmc_select_powerclass() should never really fail which means failure should be treated as fatal and we should really skip the card initialization.
This patch is already pushed to mmc-next. So I will post another patch (by next week as I will be on vacation in this week) to skip the card initialization if mmc_select_powerclass fails.

Quoted 5 lines

Is this ok?

Regards,
Subhash

There was an error in the public JEDEC eMMC 4.5 version: PWR_CL_200_360 = EXT_CSD[237] is wrongly defined because HS200 can be supported only @1.2V or 1.8V. New Jedec spec revision might fix this.

I and Danilo did a quick check in the power class selection routines and it looks like the power class is set according to the OCR parsing.
The OCR parsing to check the supported voltage range does not totally cover the device capabilities because Vccq = 1.2V support is not encoded in the register.

If the above is true, this implies that indexes EXT_CSD_PWR_CL_200_360 will lead to an error.

DEVICE_TYPE = EXT_CSD[196] is more useful because it provides information on the Speed Rate and Voltage Range supported by the device.

Cheers,
Luca

#9 lore raw

Hi Porzio,

Quoted 8 lines

-----Original Message-----
From: Luca Porzio (lporzio) [mailto:[email protected]]
Sent: Tuesday, April 03, 2012 10:36 PM
To: Subhash Jadavani; 'Saugata Das'
Cc: [email protected]; [email protected]; [email protected]; Danilo Caraccio (dcaracci)
Subject: RE: [PATCH v1 1/1] mmc: core: fix power class selection

Quoted 6 lines

Hi,

Quoted 4 lines

Yes, this makes sense. With current implementation, mmc_select_powerclass() should never really fail which means failure should be treated as fatal and we should really skip the card

initialization.

Quoted 10 lines
Quoted 9 lines

This patch is already pushed to mmc-next. So I will post another patch (by next week as I will be on vacation in this week) to skip the card initialization if mmc_select_powerclass fails.

Is this ok?

Regards,
Subhash

Quoted 5 lines

There was an error in the public JEDEC eMMC 4.5 version: PWR_CL_200_360 = EXT_CSD[237] is wrongly defined because HS200 can be supported only @1.2V or 1.8V. New Jedec spec revision might fix this.

I and Danilo did a quick check in the power class selection routines and

it looks

Quoted 2 lines

like the power class is set according to the OCR parsing. The OCR parsing to check the supported voltage range does not totally

cover

Quoted 2 lines

the device capabilities because Vccq = 1.2V support is not encoded in the register.

According to my understanding, "vvv" in "PWR_CL_ff_vvv" (or "PWR_CL_DDR_ff_vvv") indicates is VDD voltage not the VCCQ voltage. So we shouldn't bother about what is the vccq level to decide which particular field to read for power class. Please correct me if this understanding is wrong.

Regards,
Subhash

Quoted 2 lines

If the above is true, this implies that indexes EXT_CSD_PWR_CL_200_360

will

Quoted 7 lines

lead to an error.

DEVICE_TYPE = EXT_CSD[196] is more useful because it provides information on the Speed Rate and Voltage Range supported by the device.

Cheers,
Luca

#10 lore raw
In reply to Subhash Jadavani
Quoted 77 lines · Subhash Jadavani
Quoted 68 lines

-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Saugata Das
Sent: Tuesday, April 03, 2012 9:48 PM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/1] mmc: core: fix power class selection

Quoted 11 lines · Subhash Jadavani
Quoted 11 lines

-----Original Message-----
From: Saugata Das [mailto:[email protected]]
Sent: Tuesday, April 03, 2012 8:55 PM
To: Subhash Jadavani
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v1 1/1] mmc: core: fix power class selection

On 3 April 2012 12:25, Subhash Jadavani <[email protected]>

Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines

mmc_select_powerclass() function returns error if eMMC VDD level supported by host is between 2.7v to 3.2v.

According to eMMC specification, valid voltage for high voltage cards is 2.7v to 3.6v. This patch ensures that 2.7v to 3.6v VDD range is treated as valid range.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Also, failure to set the power class shouldn't be treated as fatal error because even if setting the power class fails, card can still work in default power class.
If mmc_select_powerclass() returns error, just print the warning message and go ahead with rest of the card initialization.

Have you checked why mmc_select_powerclass returned error ? Today,

in

Quoted 28 lines
Quoted 2 lines

the mmc_select_powerclass, it is just setting the value of power class,

which

Quoted 6 lines

the eMMC expects. So, it should not fail.

Another point is that, today mmc_select_powerclass is assuming that host can support the maximum possible power classes and it does not check host controllers capability in driving higher current (mA). But I think in

future we

Quoted 3 lines

need to add this check for host controller ability and return error from mmc_select_powerclass so that mmc_init_card can choose the next speed

Agreed with this point.

Quoted 2 lines

mode. From that perspective, the approach to ignore the error return from mmc_select_powerclass looks wrong.

My patch was just intended to fix the issue existing power class implementation. As commit text says:
       - don't consider 2.7v to 3.2v as invalid range
       - We are already ignoring the error returned by mmc_set_power_class() function for DS/HS/DDR cards. So this patch has extended that to HS200 cards.

So as far as this patch is concerned, I don't see anything wrong here.

Quoted 8 lines
Quoted 4 lines

As you have mentioned, currently we are not taking the host controller capability into account (as it doesn't exist as of now) so we should not see
mmc_select_powerclass() fail any time.

This is actually the main concern. The fail of mmc_select_powerclass is something to be checked and not ignored since it should not fail under the current implementation.

Quoted 8 lines

Yes, this makes sense. With current implementation, mmc_select_powerclass() should never really fail which means failure should be treated as fatal and we should really skip the card initialization.
This patch is already pushed to mmc-next. So I will post another patch (by next week as I will be on vacation in this week) to skip the card initialization if mmc_select_powerclass fails.

Is this ok?

It is OK. Thanks,

Quoted 129 lines

Regards,
Subhash

Quoted 58 lines
Quoted 6 lines

But yes, next thing should be to take into account the host current sourcing capability before deciding which bus speed mode to choose. But that may be a big change and should be as separate patch. Girish had already posted one patch for this which needs to be extended to

achieve this.

Quoted 51 lines

Regards,
Subhash

Quoted 33 lines
Quoted 33 lines

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

 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/mmc/core/mmc.c index renamed from drivers/mmc/core/mmc.c +0 -0

02914d6..54df5ad 100644

drivers/mmc/core/mmc.c +5 -0
@@ -695,6 +695,11 @@ static int mmc_select_powerclass(struct
 mmc_card *card,
                else if (host->ios.clock <= 200000000)
                        index = EXT_CSD_PWR_CL_200_195;
                break;
+       case MMC_VDD_27_28:
+       case MMC_VDD_28_29:
+       case MMC_VDD_29_30:
+       case MMC_VDD_30_31:
+       case MMC_VDD_31_32:

       case MMC_VDD_32_33:
       case MMC_VDD_33_34:
       case MMC_VDD_34_35:

drivers/mmc/core/mmc.c +0 -0
@@ -1111,11 +1116,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,

               ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ? EXT_CSD_BUS_WIDTH_8 :
EXT_CSD_BUS_WIDTH_4;
               err = mmc_select_powerclass(card, ext_csd_bits, ext_csd);
-               if (err) {
-                       pr_err("%s: power class selection to bus

Quoted 8 lines
Quoted 8 lines

width %d failed\n",
-                               mmc_hostname(card->host), 1 << bus_width);
-                       goto err;
-               }
+               if (err)
+                       pr_warning("%s: power class selection to
+ bus

width %d"

Quoted 5 lines
Quoted 5 lines

+                                  " failed\n",
+ mmc_hostname(card->host),
+                                  1 << bus_width); }

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/mmc/core/mmc.c static int mmc_init_card(struct mmc_host · line 1152

Quoted 8 lines

       /*

drivers/mmc/core/mmc.c +0 -1
@@ -1147,10 +1151,10 @@ static int mmc_init_card(struct mmc_host
 *host, u32 ocr,
                        err = mmc_select_powerclass(card,
 ext_csd_bits[idx][0],
                                                    ext_csd);
                        if (err)
-                               pr_err("%s: power class selection to

"

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

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

Quoted 5 lines
drivers/mmc/core/mmc.c +2 -3
-                                      "bus width %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width);
+                               pr_warning("%s: power class
+ selection to

"

Quoted 5 lines
Quoted 5 lines
drivers/mmc/core/mmc.c +4 -0
+                                          "bus width %d failed\n",
+
+ mmc_hostname(card->host),
+                                          1 << bus_width);
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                        EXT_CSD_BUS_WIDTH, @@ -1178,10
+1182,10 @@ static int mmc_init_card(struct mmc_host *host, u32 +ocr,
                       err = mmc_select_powerclass(card, ext_csd_bits[idx][1],
                                                   ext_csd); if (err)
-                               pr_err("%s: power class selection to

"

Quoted 23 lines
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines

-                                      "bus width %d ddr %d failed\n",
-                                      mmc_hostname(card->host),
-                                      1 << bus_width, ddr);
+                               pr_warning("%s: power class
+ selection to

"

Quoted 16 lines
Quoted 12 lines

+                                          "bus width %d ddr %d
+ failed\n",
+
+ mmc_hostname(card->host),
+                                          1 << bus_width, ddr);

                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                                        EXT_CSD_BUS_WIDTH, --
1.7.1.1

Quoted 3 lines

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

Forum.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More

majordomo

Quoted 1 line

info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in

the

Quoted 2 lines

body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html