mmc: sdhci: Do not disable interrupts while waiting for clock
authorAdrian Hunter <>
Mon, 20 Mar 2017 17:50:29 +0000 (19:50 +0200)
committerBen Hutchings <>
Tue, 18 Jul 2017 17:38:36 +0000 (18:38 +0100)
commit e2ebfb2142acefecc2496e71360f50d25726040b upstream.

Disabling interrupts for even a millisecond can cause problems for some
devices. That can happen when sdhci changes clock frequency because it
waits for the clock to become stable under a spin lock.

The spin lock is not necessary here. Anything that is racing with changes
to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host.

Although the spin lock probably should be removed from the code paths that
lead to this point, such a patch would touch too much code to be suitable
for stable trees. Consequently, for this patch, just drop the spin lock
while waiting.

Signed-off-by: Adrian Hunter <>
Signed-off-by: Ulf Hansson <>
Tested-by: Ludovic Desroches <>
Signed-off-by: Ben Hutchings <>

index 9f68b82..99bc62e 100644 (file)
@@ -1150,7 +1150,9 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
-               mdelay(1);
+               spin_unlock_irq(&host->lock);
+               usleep_range(900, 1100);
+               spin_lock_irq(&host->lock);
        clk |= SDHCI_CLOCK_CARD_EN;