public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0
@ 2017-08-01 23:58 Zhoujie Wu
  2017-08-02  7:28 ` Adrian Hunter
  2017-08-02  7:36 ` Gregory CLEMENT
  0 siblings, 2 replies; 5+ messages in thread
From: Zhoujie Wu @ 2017-08-01 23:58 UTC (permalink / raw)
  To: ulf.hansson, adrian.hunter, linux-mmc
  Cc: zmxu, jszhang, nadavh, xigu, dingwei, kostap, hannah, hongd,
	dougj, ygao, liuw, gregory.clement, thomas.petazzoni, Zhoujie Wu

One issue was found on a removable high speed sd card with
runtime pm enabled.
When SD card is unplugged, it keep printing "Switching to 3.3V
signalling voltage failed".
And found below sequence triggers the error.

mmc_rescan
	-> mmc_sd_detect
		-> mmc_power_off  -- mmc->ios.vdd is update to 0.
	-> mmc_claim_host
		-> sdhci_runtime_resume_host
			-> sdhci_start_signal_voltage_switch
				-> mmc_regulator_set_vqmmc
					-> mmc_ocrbitnum_to_vdd

When mmc_ocrbitnum_to_vdd is called, the mmc->ios.vdd is 0, so it
always return -EINVAL. The signal switch will always fail and
print out warning.

Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
---
Hi Ulf,
	Not sure if this is the best way to fix it. Please help to suggest. Thanks.

 drivers/mmc/host/sdhci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index ecd0d43..011ebbe 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1878,7 +1878,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
 		ctrl &= ~SDHCI_CTRL_VDD_180;
 		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
 
-		if (!IS_ERR(mmc->supply.vqmmc)) {
+		if ((!IS_ERR(mmc->supply.vqmmc)) && mmc->ios.vdd) {
 			ret = mmc_regulator_set_vqmmc(mmc, ios);
 			if (ret) {
 				pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0
  2017-08-01 23:58 [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0 Zhoujie Wu
@ 2017-08-02  7:28 ` Adrian Hunter
  2017-08-02 23:12   ` Zhoujie Wu
  2017-08-02  7:36 ` Gregory CLEMENT
  1 sibling, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2017-08-02  7:28 UTC (permalink / raw)
  To: Zhoujie Wu, ulf.hansson, linux-mmc
  Cc: zmxu, jszhang, nadavh, xigu, dingwei, kostap, hannah, hongd,
	dougj, ygao, liuw, gregory.clement, thomas.petazzoni

On 02/08/17 02:58, Zhoujie Wu wrote:
> One issue was found on a removable high speed sd card with
> runtime pm enabled.
> When SD card is unplugged, it keep printing "Switching to 3.3V
> signalling voltage failed".
> And found below sequence triggers the error.
> 
> mmc_rescan
> 	-> mmc_sd_detect
> 		-> mmc_power_off  -- mmc->ios.vdd is update to 0.
> 	-> mmc_claim_host
> 		-> sdhci_runtime_resume_host
> 			-> sdhci_start_signal_voltage_switch

We ought to be able to skip restoring the I/O state when the power is off i.e.:

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index cf2166e4190d..4a70f2f765b6 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2934,7 +2934,8 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)

 	sdhci_init(host, 0);

-	if (mmc->ios.power_mode != MMC_POWER_UNDEFINED) {
+	if (mmc->ios.power_mode != MMC_POWER_UNDEFINED &&
+	    mmc->ios.power_mode != MMC_POWER_OFF) {
 		/* Force clock and power re-program */
 		host->pwr = 0;
 		host->clock = 0;


> 				-> mmc_regulator_set_vqmmc
> 					-> mmc_ocrbitnum_to_vdd
> 
> When mmc_ocrbitnum_to_vdd is called, the mmc->ios.vdd is 0, so it
> always return -EINVAL. The signal switch will always fail and
> print out warning.
> 
> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
> ---
> Hi Ulf,
> 	Not sure if this is the best way to fix it. Please help to suggest. Thanks.
> 
>  drivers/mmc/host/sdhci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index ecd0d43..011ebbe 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1878,7 +1878,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
>  		ctrl &= ~SDHCI_CTRL_VDD_180;
>  		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
>  
> -		if (!IS_ERR(mmc->supply.vqmmc)) {
> +		if ((!IS_ERR(mmc->supply.vqmmc)) && mmc->ios.vdd) {
>  			ret = mmc_regulator_set_vqmmc(mmc, ios);
>  			if (ret) {
>  				pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
> 


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0
  2017-08-01 23:58 [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0 Zhoujie Wu
  2017-08-02  7:28 ` Adrian Hunter
@ 2017-08-02  7:36 ` Gregory CLEMENT
  2017-08-02 22:33   ` Zhoujie Wu
  1 sibling, 1 reply; 5+ messages in thread
From: Gregory CLEMENT @ 2017-08-02  7:36 UTC (permalink / raw)
  To: Zhoujie Wu, ulf.hansson, adrian.hunter
  Cc: linux-mmc, zmxu, jszhang, nadavh, xigu, dingwei, kostap, hannah,
	hongd, dougj, ygao, liuw, thomas.petazzoni

Hi Zhoujie, Adrian and Ulf, 
 
 On mar., août 01 2017, Zhoujie Wu <zjwu@marvell.com> wrote:

> One issue was found on a removable high speed sd card with
> runtime pm enabled.
> When SD card is unplugged, it keep printing "Switching to 3.3V
> signalling voltage failed".
> And found below sequence triggers the error.
>
> mmc_rescan
> 	-> mmc_sd_detect
> 		-> mmc_power_off  -- mmc->ios.vdd is update to 0.
> 	-> mmc_claim_host
> 		-> sdhci_runtime_resume_host
> 			-> sdhci_start_signal_voltage_switch
> 				-> mmc_regulator_set_vqmmc
> 					-> mmc_ocrbitnum_to_vdd
>
> When mmc_ocrbitnum_to_vdd is called, the mmc->ios.vdd is 0, so it
> always return -EINVAL. The signal switch will always fail and
> print out warning.
>
> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
> ---
> Hi Ulf,
> 	Not sure if this is the best way to fix it. Please help to
> suggest. Thanks.

I don't know if there is a link, but I observed that when the kernel
boot with an UHS SD Card plugged (and after a warm reset) then the bus
speed is only "High Speed". Whereas if I plugged it while the kernel is
running the "Ultra " speed is detected.

I observed that with the sdhci-xenon driver, but I don't have any other
UHS capable controller available to compare it and to know if it is
something at sdhci level or at xenon level.

Thanks,

Gregory

>
>  drivers/mmc/host/sdhci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index ecd0d43..011ebbe 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1878,7 +1878,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
>  		ctrl &= ~SDHCI_CTRL_VDD_180;
>  		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
>  
> -		if (!IS_ERR(mmc->supply.vqmmc)) {
> +		if ((!IS_ERR(mmc->supply.vqmmc)) && mmc->ios.vdd) {
>  			ret = mmc_regulator_set_vqmmc(mmc, ios);
>  			if (ret) {
>  				pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
> -- 
> 1.9.1
>

-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0
  2017-08-02  7:36 ` Gregory CLEMENT
@ 2017-08-02 22:33   ` Zhoujie Wu
  0 siblings, 0 replies; 5+ messages in thread
From: Zhoujie Wu @ 2017-08-02 22:33 UTC (permalink / raw)
  To: Gregory CLEMENT, ulf.hansson, adrian.hunter
  Cc: linux-mmc, zmxu, jszhang, nadavh, xigu, dingwei, kostap, hannah,
	hongd, dougj, ygao, liuw, thomas.petazzoni

Hi Gregory,
Thanks for your response.

On 08/02/2017 12:36 AM, Gregory CLEMENT wrote:
> Hi Zhoujie, Adrian and Ulf,
>   
>   On mar., août 01 2017, Zhoujie Wu <zjwu@marvell.com> wrote:
>
>> One issue was found on a removable high speed sd card with
>> runtime pm enabled.
>> When SD card is unplugged, it keep printing "Switching to 3.3V
>> signalling voltage failed".
>> And found below sequence triggers the error.
>>
>> mmc_rescan
>> 	-> mmc_sd_detect
>> 		-> mmc_power_off  -- mmc->ios.vdd is update to 0.
>> 	-> mmc_claim_host
>> 		-> sdhci_runtime_resume_host
>> 			-> sdhci_start_signal_voltage_switch
>> 				-> mmc_regulator_set_vqmmc
>> 					-> mmc_ocrbitnum_to_vdd
>>
>> When mmc_ocrbitnum_to_vdd is called, the mmc->ios.vdd is 0, so it
>> always return -EINVAL. The signal switch will always fail and
>> print out warning.
>>
>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>> ---
>> Hi Ulf,
>> 	Not sure if this is the best way to fix it. Please help to
>> suggest. Thanks.
> I don't know if there is a link, but I observed that when the kernel
> boot with an UHS SD Card plugged (and after a warm reset) then the bus
> speed is only "High Speed". Whereas if I plugged it while the kernel is
> running the "Ultra " speed is detected.
>
> I observed that with the sdhci-xenon driver, but I don't have any other
> UHS capable controller available to compare it and to know if it is
> something at sdhci level or at xenon level.

I observed the same behavior as you. I added some logs and I found the 
difference comes from when init card mmc_sd_get_cid got different ocr 
response from SD card.

When boot up board with sd card plugged, SD card ocr response didn't set 
S18A bit(bit24 of rocr), so driver won't switch to uhs mode.

[    4.162597] ocr = 41200000

[    4.236465] rocr = c0ff8000

If I unplugged the card and plugged it again, this time SD ocr response 
set S18A bit(bit24 of rocr), then driver will switch to uhs mode after that.

[   33.817272] ocr = 41200000

[   33.920454] rocr = c1ff8000

Currently I have no idea why SD card response different in these two 
cases. I will check more details later.

>
> Thanks,
>
> Gregory
>
>>   drivers/mmc/host/sdhci.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index ecd0d43..011ebbe 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -1878,7 +1878,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
>>   		ctrl &= ~SDHCI_CTRL_VDD_180;
>>   		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
>>   
>> -		if (!IS_ERR(mmc->supply.vqmmc)) {
>> +		if ((!IS_ERR(mmc->supply.vqmmc)) && mmc->ios.vdd) {
>>   			ret = mmc_regulator_set_vqmmc(mmc, ios);
>>   			if (ret) {
>>   				pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
>> -- 
>> 1.9.1
>>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0
  2017-08-02  7:28 ` Adrian Hunter
@ 2017-08-02 23:12   ` Zhoujie Wu
  0 siblings, 0 replies; 5+ messages in thread
From: Zhoujie Wu @ 2017-08-02 23:12 UTC (permalink / raw)
  To: Adrian Hunter, ulf.hansson, linux-mmc
  Cc: zmxu, jszhang, nadavh, xigu, dingwei, kostap, hannah, hongd,
	dougj, ygao, liuw, gregory.clement, thomas.petazzoni

Hi Adrian,

On 08/02/2017 12:28 AM, Adrian Hunter wrote:
> On 02/08/17 02:58, Zhoujie Wu wrote:
>> One issue was found on a removable high speed sd card with
>> runtime pm enabled.
>> When SD card is unplugged, it keep printing "Switching to 3.3V
>> signalling voltage failed".
>> And found below sequence triggers the error.
>>
>> mmc_rescan
>> 	-> mmc_sd_detect
>> 		-> mmc_power_off  -- mmc->ios.vdd is update to 0.
>> 	-> mmc_claim_host
>> 		-> sdhci_runtime_resume_host
>> 			-> sdhci_start_signal_voltage_switch
> We ought to be able to skip restoring the I/O state when the power is off i.e.:
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index cf2166e4190d..4a70f2f765b6 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2934,7 +2934,8 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
>
>   	sdhci_init(host, 0);
>
> -	if (mmc->ios.power_mode != MMC_POWER_UNDEFINED) {
> +	if (mmc->ios.power_mode != MMC_POWER_UNDEFINED &&
> +	    mmc->ios.power_mode != MMC_POWER_OFF) {
>   		/* Force clock and power re-program */
>   		host->pwr = 0;
>   		host->clock = 0;

Your suggestion works and better than mine. I will do more tests and 
update the patch later. thanks.
>
>
>> 				-> mmc_regulator_set_vqmmc
>> 					-> mmc_ocrbitnum_to_vdd
>>
>> When mmc_ocrbitnum_to_vdd is called, the mmc->ios.vdd is 0, so it
>> always return -EINVAL. The signal switch will always fail and
>> print out warning.
>>
>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>> ---
>> Hi Ulf,
>> 	Not sure if this is the best way to fix it. Please help to suggest. Thanks.
>>
>>   drivers/mmc/host/sdhci.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index ecd0d43..011ebbe 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -1878,7 +1878,7 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
>>   		ctrl &= ~SDHCI_CTRL_VDD_180;
>>   		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
>>   
>> -		if (!IS_ERR(mmc->supply.vqmmc)) {
>> +		if ((!IS_ERR(mmc->supply.vqmmc)) && mmc->ios.vdd) {
>>   			ret = mmc_regulator_set_vqmmc(mmc, ios);
>>   			if (ret) {
>>   				pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
>>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-02 23:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 23:58 [PATCH] mmc: sdhci: ignore 3.3v voltage switch if ios.vdd is 0 Zhoujie Wu
2017-08-02  7:28 ` Adrian Hunter
2017-08-02 23:12   ` Zhoujie Wu
2017-08-02  7:36 ` Gregory CLEMENT
2017-08-02 22:33   ` Zhoujie Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox