• Jisheng Zhang's avatar
    mmc: sdhci-pxav3: fix unbalanced clock issues during probe · a5c11323
    Jisheng Zhang authored
    commit 62cf983a upstream.
    
    Commit 0dcaa249 ("sdhci-pxav3: Fix runtime PM initialization") tries
    to fix one hang issue caused by calling sdhci_add_host() on a suspended
    device. The fix enables the clock twice, once by clk_prepare_enable() and
    another by pm_runtime_get_sync(), meaning that the clock will never be
    gated at runtime PM suspend. I observed the power consumption regression on
    Marvell BG2Q SoCs.
    
    In fact, the fix is not correct. There still be a very small window
    during which a runtime suspend might somehow occur after pm_runtime_enable()
    but before pm_runtime_get_sync().
    
    This patch fixes all of the two problems by just incrementing the usage
    counter before pm_runtime_enable(). It also adjust the order of disabling
    runtime pm and storing the usage count in the error path to handle clock
    gating properly.
    Signed-off-by: default avatarJisheng Zhang <jszhang@marvell.com>
    Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
    a5c11323
sdhci-pxav3.c 12.4 KB