mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-12 08:09:56 +00:00
mmc: msm_sdcc: Fix issue where clocks could be disabled mid transaction
msmsdcc_enable_clocks() was incorrectly being called depending on the state of host->clks_on. This means the busclk idle timer was never being deleted if the clock was already on.. Bogus. Also fixes a possible double clk disable if the call to del_timer_sync() in msmsdcc_disable_clocks() raced with the busclk timer. Signed-off-by: San Mehat <san@google.com> Signed-off-by: Daniel Walker <dwalker@codeaurora.org>
This commit is contained in:
parent
6ac9ea6906
commit
d0719e59f4
@ -61,7 +61,7 @@ static unsigned int msmsdcc_sdioirq;
|
|||||||
#define CMD_SPINMAX 20
|
#define CMD_SPINMAX 20
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
msmsdcc_disable_clocks(struct msmsdcc_host *host, int deferr)
|
msmsdcc_disable_clocks(struct msmsdcc_host *host, int deferr)
|
||||||
{
|
{
|
||||||
WARN_ON(!host->clks_on);
|
WARN_ON(!host->clks_on);
|
||||||
@ -72,9 +72,14 @@ msmsdcc_disable_clocks(struct msmsdcc_host *host, int deferr)
|
|||||||
mod_timer(&host->busclk_timer, jiffies + BUSCLK_TIMEOUT);
|
mod_timer(&host->busclk_timer, jiffies + BUSCLK_TIMEOUT);
|
||||||
} else {
|
} else {
|
||||||
del_timer_sync(&host->busclk_timer);
|
del_timer_sync(&host->busclk_timer);
|
||||||
clk_disable(host->clk);
|
/* Need to check clks_on again in case the busclk
|
||||||
clk_disable(host->pclk);
|
* timer fired
|
||||||
host->clks_on = 0;
|
*/
|
||||||
|
if (host->clks_on) {
|
||||||
|
clk_disable(host->clk);
|
||||||
|
clk_disable(host->pclk);
|
||||||
|
host->clks_on = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,21 +88,21 @@ msmsdcc_enable_clocks(struct msmsdcc_host *host)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
WARN_ON(host->clks_on);
|
|
||||||
|
|
||||||
del_timer_sync(&host->busclk_timer);
|
del_timer_sync(&host->busclk_timer);
|
||||||
|
|
||||||
rc = clk_enable(host->pclk);
|
if (!host->clks_on) {
|
||||||
if (rc)
|
rc = clk_enable(host->pclk);
|
||||||
return rc;
|
if (rc)
|
||||||
rc = clk_enable(host->clk);
|
return rc;
|
||||||
if (rc) {
|
rc = clk_enable(host->clk);
|
||||||
clk_disable(host->pclk);
|
if (rc) {
|
||||||
return rc;
|
clk_disable(host->pclk);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
udelay(1 + ((3 * USEC_PER_SEC) /
|
||||||
|
(host->clk_rate ? host->clk_rate : msmsdcc_fmin)));
|
||||||
|
host->clks_on = 1;
|
||||||
}
|
}
|
||||||
udelay(1 + ((3 * USEC_PER_SEC) /
|
|
||||||
(host->clk_rate ? host->clk_rate : msmsdcc_fmin)));
|
|
||||||
host->clks_on = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +185,8 @@ msmsdcc_dma_exec_func(struct msm_dmov_cmd *cmd)
|
|||||||
struct msmsdcc_host *host = (struct msmsdcc_host *)cmd->data;
|
struct msmsdcc_host *host = (struct msmsdcc_host *)cmd->data;
|
||||||
|
|
||||||
msmsdcc_writel(host, host->cmd_timeout, MMCIDATATIMER);
|
msmsdcc_writel(host, host->cmd_timeout, MMCIDATATIMER);
|
||||||
msmsdcc_writel(host, (unsigned int)host->curr.xfer_size, MMCIDATALENGTH);
|
msmsdcc_writel(host, (unsigned int)host->curr.xfer_size,
|
||||||
|
MMCIDATALENGTH);
|
||||||
msmsdcc_writel(host, host->cmd_pio_irqmask, MMCIMASK1);
|
msmsdcc_writel(host, host->cmd_pio_irqmask, MMCIMASK1);
|
||||||
msmsdcc_writel(host, host->cmd_datactrl, MMCIDATACTRL);
|
msmsdcc_writel(host, host->cmd_datactrl, MMCIDATACTRL);
|
||||||
|
|
||||||
@ -854,13 +860,7 @@ msmsdcc_request(struct mmc_host *mmc, struct mmc_request *mrq)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to drop the host lock here in case
|
msmsdcc_enable_clocks(host);
|
||||||
* the busclk wd fires
|
|
||||||
*/
|
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
|
||||||
if (!host->clks_on)
|
|
||||||
msmsdcc_enable_clocks(host);
|
|
||||||
spin_lock_irqsave(&host->lock, flags);
|
|
||||||
|
|
||||||
host->curr.mrq = mrq;
|
host->curr.mrq = mrq;
|
||||||
|
|
||||||
@ -893,11 +893,10 @@ msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
int rc;
|
int rc;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!host->clks_on)
|
|
||||||
msmsdcc_enable_clocks(host);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&host->lock, flags);
|
spin_lock_irqsave(&host->lock, flags);
|
||||||
|
|
||||||
|
msmsdcc_enable_clocks(host);
|
||||||
|
|
||||||
if (ios->clock) {
|
if (ios->clock) {
|
||||||
if (ios->clock != host->clk_rate) {
|
if (ios->clock != host->clk_rate) {
|
||||||
rc = clk_set_rate(host->clk, ios->clock);
|
rc = clk_set_rate(host->clk, ios->clock);
|
||||||
@ -1026,13 +1025,9 @@ static void
|
|||||||
msmsdcc_busclk_expired(unsigned long _data)
|
msmsdcc_busclk_expired(unsigned long _data)
|
||||||
{
|
{
|
||||||
struct msmsdcc_host *host = (struct msmsdcc_host *) _data;
|
struct msmsdcc_host *host = (struct msmsdcc_host *) _data;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&host->lock, flags);
|
|
||||||
dev_info(mmc_dev(host->mmc), "Bus clock timer expired\n");
|
|
||||||
if (host->clks_on)
|
if (host->clks_on)
|
||||||
msmsdcc_disable_clocks(host, 0);
|
msmsdcc_disable_clocks(host, 0);
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1324,10 +1319,8 @@ msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
|
|||||||
|
|
||||||
if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
|
if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
|
||||||
rc = mmc_suspend_host(mmc, state);
|
rc = mmc_suspend_host(mmc, state);
|
||||||
if (!rc) {
|
if (!rc)
|
||||||
msmsdcc_writel(host, 0, MMCIMASK0);
|
msmsdcc_writel(host, 0, MMCIMASK0);
|
||||||
|
|
||||||
}
|
|
||||||
if (host->clks_on)
|
if (host->clks_on)
|
||||||
msmsdcc_disable_clocks(host, 0);
|
msmsdcc_disable_clocks(host, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user