]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
MLK-9413 mmc: sdhci: fix potential unblanced regulator disable
authorDong Aisheng <b29396@freescale.com>
Wed, 19 Nov 2014 07:20:09 +0000 (15:20 +0800)
committerDong Aisheng <b29396@freescale.com>
Wed, 21 Jan 2015 08:03:06 +0000 (16:03 +0800)
The host->vmmc will be in disabled state if there's no card detected.
In that case arbitrarily disabling the host->vmmc in sdhci_remove_host()
may cause the following warning due to unblanced use count of regulator.

root@imx6qdlsolo:~# modprobe -r sdhci-esdhc-imx
mmc3: card e624 removed
------------[ cut here ]------------
WARNING: at drivers/regulator/core.c:1727 _regulator_disable+0xe4/0x14c()
unbalanced disables for VCC_SD3
Modules linked in: sdhci_esdhc_imx(-) sdhci_pltfm
CPU: 0 PID: 884 Comm: modprobe Not tainted 3.10.53-02577-gd22d937 #715
[<80013b00>] (unwind_backtrace+0x0/0xf4) from [<80011524>] (show_stack+0x10/0x14)
[<80011524>] (show_stack+0x10/0x14) from [<8002c290>] (warn_slowpath_common+0x54/0x6c)
[<8002c290>] (warn_slowpath_common+0x54/0x6c) from [<8002c2d8>] (warn_slowpath_fmt+0x30/0x40)
[<8002c2d8>] (warn_slowpath_fmt+0x30/0x40) from [<802cc054>] (_regulator_disable+0xe4/0x14c)
[<802cc054>] (_regulator_disable+0xe4/0x14c) from [<802cc0ec>] (regulator_disable+0x30/0x64)
[<802cc0ec>] (regulator_disable+0x30/0x64) from [<80468dfc>] (sdhci_remove_host+0x78/0x160)
[<80468dfc>] (sdhci_remove_host+0x78/0x160) from [<7f005934>] (sdhci_esdhc_imx_remove+0x30/0x58 [sdhci_esdhc_imx])
[<7f005934>] (sdhci_esdhc_imx_remove+0x30/0x58 [sdhci_esdhc_imx]) from [<80313038>] (platform_drv_remove+0x18/0x1c)
[<80313038>] (platform_drv_remove+0x18/0x1c) from [<803119d8>] (__device_release_driver+0x70/0xcc)
[<803119d8>] (__device_release_driver+0x70/0xcc) from [<803120cc>] (driver_detach+0xac/0xb0)
[<803120cc>] (driver_detach+0xac/0xb0) from [<803116c4>] (bus_remove_driver+0x7c/0xd0)
[<803116c4>] (bus_remove_driver+0x7c/0xd0) from [<8006fc80>] (SyS_delete_module+0x124/0x210)
[<8006fc80>] (SyS_delete_module+0x124/0x210) from [<8000e080>] (ret_fast_syscall+0x0/0x30)
---[ end trace 7bd0fb3a78254b54 ]---
root@imx6qdlsolo:~# EXT3-fs (mmcblk3p2): I/O error while writing superblock

Only disable regulators if they're on when remove host controller.

Signed-off-by: Dong Aisheng <b29396@freescale.com>
(cherry picked from commit 89aa41ebb49c495be76ce107d037e4f31b3671cd)
(cherry picked from commit 5f2ea9ff90daa3e99512c4c7c453278910b78f34)

drivers/mmc/host/sdhci.c

index bbf2f5399702ed0a6cb39609e2d8ee5c2bf508f9..abfd222bd38820469c6840ee49785b0d9be6606c 100644 (file)
@@ -3425,12 +3425,14 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
        tasklet_kill(&host->finish_tasklet);
 
        if (host->vmmc) {
-               regulator_disable(host->vmmc);
+               if (regulator_is_enabled(host->vmmc))
+                       regulator_disable(host->vmmc);
                regulator_put(host->vmmc);
        }
 
        if (host->vqmmc) {
-               regulator_disable(host->vqmmc);
+               if (regulator_is_enabled(host->vqmmc))
+                       regulator_disable(host->vqmmc);
                regulator_put(host->vqmmc);
        }