Bug 50711 - [TRIVIAL]sdhci-pci: could not set regulator OCR (-22)
Summary: [TRIVIAL]sdhci-pci: could not set regulator OCR (-22)
Status: RESOLVED OBSOLETE
Alias: None
Product: Drivers
Classification: Unclassified
Component: MMC/SD (show other bugs)
Hardware: All Linux
: P1 high
Assignee: drivers_mmc-sd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-19 00:07 UTC by Alan Bartlett
Modified: 2013-11-20 14:43 UTC (History)
5 users (show)

See Also:
Kernel Version: 3.6.6
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments
Dmesg and other relevant output. (74.02 KB, text/plain)
2012-11-19 00:07 UTC, Alan Bartlett
Details
Patch which allows the card readers from this report to work again under kernels 3.7.x (tested on 3.7.6). (1.05 KB, patch)
2013-02-05 13:03 UTC, Lukasz Masko
Details | Diff

Description Alan Bartlett 2012-11-19 00:07:46 UTC
Created attachment 86581 [details]
Dmesg and other relevant output.

Device: 02:01.2 SD Host controller [0805]: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter [1180:0822] (rev 21)

OS: RHEL 6u3

Arch: x86_64

3.0.51 kernel -- o.k.

3.1.10 kernel -- o.k.

3.2.33 kernel -- o.k.

3.3.8 kernel -- first sign of a problem. "sdhci-pci 0000:02:01.2: could not set regulator OCR (-22)". Cards are still accessible.

3.4.18 kernel -- "sdhci-pci 0000:02:01.2: could not set regulator OCR (-22)". Cards are still accessible.

3.5.7 kernel -- "sdhci-pci 0000:02:01.2: could not set regulator OCR (-22)". Cards are still accessible.

3.6.6 kernel -- "mmc0: Hardware doesn't report any support voltages.". Cards are not accessible.

For each of the above seven kernels, I have comprehensive logs of the tests performed. The log for the 3.6.6 kernel is attached. Others can be supplied, upon request.
Comment 1 Alan Bartlett 2012-12-09 23:36:42 UTC
I have the hardware available for testing and can readily build a new kernel. 

All I would need is a patch and the advice as to which kernel sources it should be applied.
Comment 2 Lukasz Masko 2013-01-28 22:04:18 UTC
Just to make sure, this report is not forgotten - I have exactly the same problem, but a different distro, so it is not distribution-speciffic.

02:01.2 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 18) (prog-if 01)
Comment 3 Alan Bartlett 2013-01-28 22:54:18 UTC
Bumping the assignee to say that I have the hardware and I have the ability to build/package kernels, however I do not understand the hardware (regulator and/or Ricoh R5C822 Host Adapter) at register/device level. Hence I am unable to de-bug this issue, myself.

I am ready and willing to perform tests -- I just need some code.

As such, any kernel >= 3.6.6 is useless for me.

I am pleased to see comment #2, from Lukasz, for I was feeling rather lonely here!
Comment 4 Lukasz Masko 2013-02-05 13:01:41 UTC
Thanks to Marek Szyprowski, I've managed to make kernel 3.7.6 work with my reader. I'm still getting these errors (sdhci-pci: could not set regulator OCR (-22)), but I can access my cards. Everything requires the following patch (thanks to Marek):

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 042c1ff..d07c240 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1872,7 +1872,14 @@ int regulator_count_voltages(struct regulator *regulator)
 {
        struct regulator_dev    *rdev = regulator->rdev;

-       return rdev->desc->n_voltages ? : -EINVAL;
+       if (rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE) {
+               if (rdev->desc->n_voltages)
+                       return rdev->desc->n_voltages;
+               else
+                       return -EINVAL;
+       } else {
+               return 1;
+       }
 }
 EXPORT_SYMBOL_GPL(regulator_count_voltages);

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c7851c0..6f6534e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2923,7 +2923,7 @@ int sdhci_add_host(struct sdhci_host *host)
                regulator_enable(host->vmmc);

 #ifdef CONFIG_REGULATOR
-       if (host->vmmc) {
+       if (host->vmmc && regulator_count_voltages(host->vmmc) > 1) {
                ret = regulator_is_supported_voltage(host->vmmc, 3300000,
                        3300000);
                if ((ret <= 0) || (!(caps[0] & SDHCI_CAN_VDD_330)))
--------
Comment 5 Lukasz Masko 2013-02-05 13:03:53 UTC
Created attachment 92531 [details]
Patch which allows the card readers from this report to work again under kernels 3.7.x (tested on 3.7.6).
Comment 6 Lukasz Masko 2013-02-05 19:08:46 UTC
Here is the original thread on the linux-kernel-mmc list, where one can find this patch (in fact part 2 and 3 are needed, the first part has been applied in the kernel already).
http://thread.gmane.org/gmane.linux.kernel.mmc/17643
Comment 7 Alan Bartlett 2013-03-16 19:59:35 UTC
Bumping this issue, once again, so that it does not get 'forgotten'.

The regression appeared in linux-3.3.X and is still present in linux-3.8.X

I have the hardware available for testing. I can build a kernel for testing.

This issue needs to be assigned to someone capable of understanding the internal workings of the patch(es) introduced in linux-3.3.X that has caused this regression and is prepared to fix the code.
Comment 8 Alan Bartlett 2013-04-06 21:16:21 UTC
This regression is still present in linux-3.9-rc5

Ignoring it will not make it go away.

Any comments? Anybody?
Comment 9 Chris Ball 2013-04-17 12:49:40 UTC
Setting CONFIG_REGULATOR=n will fix your problem, and I think just setting CONFIG_REGULATOR_DUMMY=n would too.  If you're using sdhci-pci, I think you're on a system without any regulators.

(CONFIG_REGULATOR_DUMMY should only be set if you are developing a regulator driver; if you're using a distribution kernel that has it turned on, please report a bug in your distribution asking for it to be disabled.)
Comment 10 Lukasz Masko 2013-04-17 20:12:07 UTC
(In reply to comment #9)
> Setting CONFIG_REGULATOR=n will fix your problem, and I think just setting
> CONFIG_REGULATOR_DUMMY=n would too.  If you're using sdhci-pci, I think
> you're
> on a system without any regulators.

YES, it works for me! And no longer all these annoying "could not set regulator OCR (-22)" messages. Now I have to push it into my distro ;-)
Comment 11 Alan Bartlett 2013-04-17 23:37:02 UTC
(In reply to comment #9)
> Setting CONFIG_REGULATOR=n will fix your problem, and I think just setting
> CONFIG_REGULATOR_DUMMY=n would too.  If you're using sdhci-pci, I think
> you're
> on a system without any regulators.
> 
> (CONFIG_REGULATOR_DUMMY should only be set if you are developing a regulator
> driver; if you're using a distribution kernel that has it turned on, please
> report a bug in your distribution asking for it to be disabled.)

Thank you for your assistance, Chris. I am always a little wary when someone uses the phrase "I think" but you have "hit the nail on the head". 

The mischief was created by having CONFIG_REGULATOR_DUMMY being set. Turning it off and building from the linux-3.8.8 tarball resulted in a kernel that: 

(1) Booted without displaying either the "sdhci-pci: could not set regulator OCR (-22)" or the "mmc0: Hardware doesn't report any support voltages" message.

(2) Had a fully functioning card reader/writer.

Perhaps the Kconfig file should be updated to clarify the intended usage of the CONFIG_REGULATOR_DUMMY setting?

Note You need to log in before you can comment on or make changes to this bug.