]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
mmc: sdhci: SD tuning is broken for some controllers
authorAl Cooper <alcooperx@gmail.com>
Fri, 9 May 2014 15:34:07 +0000 (11:34 -0400)
committerChris Ball <chris@printf.net>
Thu, 22 May 2014 12:40:46 +0000 (08:40 -0400)
commit7ce45e950624bee09381c3fd727f06262bcb73e2
tree5146a958f4bce89a9e5313800d321965b97266d3
parent69f5bf38f93c78faeb93d51dc41adf51e13fe78d
mmc: sdhci: SD tuning is broken for some controllers

The SD Host Controller spec states that the SD Host Controller can
request that the driver send up to 40 CMD19's while doing tuning
and that the total time the card spends responding must be < 150ms.
The sdhci_execute_tuning() function in sdhci.c that loops through
sending the CMD19's has multiple bugs. First it sets a "timeout"
variable to 150 and a loop counter variable to 40. It then decrements
both variables by 1 at the end of each loop. It tries to handle
violations of the count and time by doing a break when BOTH variables
are equal to zero, which can never happen because they we set to
different values and decremented by 1 at the same time. The timeout
variable is not based on time at all and is totally useless.
The routine also considers a loop counter of zero to be an error
which means that any controller that requests the max of 40 CMD19s
will cause tuning to fail and be disabled.

I've fixed these issues by allowing up to 40 CMD19's and I've removed
any attempt to handle the 150ms time limit. Removing timeout checking
seems safe here because each CMD19 is timeout protected and the max
loop counters insures we don't loop forever. Adding timeout checking
would not be as simple as snapping the time at the loop start and
checking for 150ms to pass because the loop queues the CMD19's and
uses events to wait for completion so the time would include
all the normal scheduler latencies.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
drivers/mmc/host/sdhci.c