mirror of https://gitee.com/openkylin/linux.git
mmc: msm_sdcc: Fix bug where busclk expiry timer was not properly disabled
Signed-off-by: San Mehat <san@google.com> Signed-off-by: Daniel Walker <dwalker@codeaurora.org>
This commit is contained in:
parent
56a8b5b8ae
commit
c7fc9370df
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
#define DRIVER_NAME "msm-sdcc"
|
#define DRIVER_NAME "msm-sdcc"
|
||||||
|
|
||||||
#define BUSCLK_TIMEOUT (HZ * 5)
|
#define BUSCLK_TIMEOUT (HZ)
|
||||||
static unsigned int msmsdcc_fmin = 144000;
|
static unsigned int msmsdcc_fmin = 144000;
|
||||||
static unsigned int msmsdcc_fmax = 50000000;
|
static unsigned int msmsdcc_fmax = 50000000;
|
||||||
static unsigned int msmsdcc_4bit = 1;
|
static unsigned int msmsdcc_4bit = 1;
|
||||||
|
@ -60,29 +60,42 @@ static unsigned int msmsdcc_sdioirq;
|
||||||
#define CMD_SPINMAX 20
|
#define CMD_SPINMAX 20
|
||||||
|
|
||||||
|
|
||||||
static inline int
|
static inline void
|
||||||
msmsdcc_enable_clocks(struct msmsdcc_host *host, int enable)
|
msmsdcc_disable_clocks(struct msmsdcc_host *host, int deferr)
|
||||||
{
|
{
|
||||||
int rc;
|
WARN_ON(!host->clks_on);
|
||||||
|
|
||||||
WARN_ON(enable == host->clks_on);
|
if (deferr) {
|
||||||
if (enable) {
|
mod_timer(&host->busclk_timer, jiffies + BUSCLK_TIMEOUT);
|
||||||
rc = clk_enable(host->pclk);
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
rc = clk_enable(host->clk);
|
|
||||||
if (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;
|
|
||||||
} else {
|
} else {
|
||||||
|
del_timer_sync(&host->busclk_timer);
|
||||||
|
// dev_info(mmc_dev(host->mmc), "Immediate clock shutdown\n");
|
||||||
clk_disable(host->clk);
|
clk_disable(host->clk);
|
||||||
clk_disable(host->pclk);
|
clk_disable(host->pclk);
|
||||||
host->clks_on = 0;
|
host->clks_on = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
msmsdcc_enable_clocks(struct msmsdcc_host *host)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
WARN_ON(host->clks_on);
|
||||||
|
|
||||||
|
del_timer_sync(&host->busclk_timer);
|
||||||
|
|
||||||
|
rc = clk_enable(host->pclk);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
rc = clk_enable(host->clk);
|
||||||
|
if (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;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,8 +131,7 @@ msmsdcc_request_end(struct msmsdcc_host *host, struct mmc_request *mrq)
|
||||||
if (mrq->cmd->error == -ETIMEDOUT)
|
if (mrq->cmd->error == -ETIMEDOUT)
|
||||||
mdelay(5);
|
mdelay(5);
|
||||||
|
|
||||||
if (host->use_bustimer)
|
msmsdcc_disable_clocks(host, 1);
|
||||||
mod_timer(&host->busclk_timer, jiffies + BUSCLK_TIMEOUT);
|
|
||||||
/*
|
/*
|
||||||
* Need to drop the host lock here; mmc_request_done may call
|
* Need to drop the host lock here; mmc_request_done may call
|
||||||
* back into the driver...
|
* back into the driver...
|
||||||
|
@ -240,12 +252,12 @@ msmsdcc_dma_complete_func(struct msm_dmov_cmd *cmd,
|
||||||
if (!mrq->data->error)
|
if (!mrq->data->error)
|
||||||
host->curr.data_xfered = host->curr.xfer_size;
|
host->curr.data_xfered = host->curr.xfer_size;
|
||||||
if (!mrq->data->stop || mrq->cmd->error) {
|
if (!mrq->data->stop || mrq->cmd->error) {
|
||||||
msmsdcc_writel(host, 0, MMCICOMMAND);
|
|
||||||
host->curr.mrq = NULL;
|
host->curr.mrq = NULL;
|
||||||
host->curr.cmd = NULL;
|
host->curr.cmd = NULL;
|
||||||
mrq->data->bytes_xfered = host->curr.data_xfered;
|
mrq->data->bytes_xfered = host->curr.data_xfered;
|
||||||
|
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
spin_unlock_irqrestore(&host->lock, flags);
|
||||||
|
msmsdcc_disable_clocks(host, 1);
|
||||||
mmc_request_done(host->mmc, mrq);
|
mmc_request_done(host->mmc, mrq);
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
|
@ -835,8 +847,14 @@ msmsdcc_request(struct mmc_host *mmc, struct mmc_request *mrq)
|
||||||
}
|
}
|
||||||
|
|
||||||
host->curr.mrq = mrq;
|
host->curr.mrq = mrq;
|
||||||
|
|
||||||
|
/* Need to drop the host lock here in case
|
||||||
|
* the busclk wd fires
|
||||||
|
*/
|
||||||
|
spin_unlock_irqrestore(&host->lock, flags);
|
||||||
if (!host->clks_on)
|
if (!host->clks_on)
|
||||||
msmsdcc_enable_clocks(host, 1);
|
msmsdcc_enable_clocks(host);
|
||||||
|
spin_lock_irqsave(&host->lock, flags);
|
||||||
|
|
||||||
if (mrq->data && mrq->data->flags & MMC_DATA_READ)
|
if (mrq->data && mrq->data->flags & MMC_DATA_READ)
|
||||||
/* Queue/read data, daisy-chain command when data starts */
|
/* Queue/read data, daisy-chain command when data starts */
|
||||||
|
@ -867,9 +885,10 @@ msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
int rc;
|
int rc;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&host->lock, flags);
|
|
||||||
if (!host->clks_on)
|
if (!host->clks_on)
|
||||||
msmsdcc_enable_clocks(host, 1);
|
msmsdcc_enable_clocks(host);
|
||||||
|
|
||||||
|
spin_lock_irqsave(&host->lock, flags);
|
||||||
|
|
||||||
if (ios->clock) {
|
if (ios->clock) {
|
||||||
if (ios->clock != host->clk_rate) {
|
if (ios->clock != host->clk_rate) {
|
||||||
|
@ -915,8 +934,7 @@ msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
||||||
host->pwr = pwr;
|
host->pwr = pwr;
|
||||||
msmsdcc_writel(host, pwr, MMCIPOWER);
|
msmsdcc_writel(host, pwr, MMCIPOWER);
|
||||||
}
|
}
|
||||||
if (host->clks_on)
|
msmsdcc_disable_clocks(host, 1);
|
||||||
msmsdcc_enable_clocks(host, 0);
|
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
spin_unlock_irqrestore(&host->lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1001,9 +1019,9 @@ msmsdcc_busclk_expired(unsigned long _data)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&host->lock, 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_enable_clocks(host, 0);
|
msmsdcc_disable_clocks(host, 0);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
spin_unlock_irqrestore(&host->lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1110,8 +1128,6 @@ msmsdcc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
host->cmdpoll = 1;
|
host->cmdpoll = 1;
|
||||||
|
|
||||||
host->use_bustimer = 1;
|
|
||||||
|
|
||||||
host->base = ioremap(memres->start, PAGE_SIZE);
|
host->base = ioremap(memres->start, PAGE_SIZE);
|
||||||
if (!host->base) {
|
if (!host->base) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
@ -1143,7 +1159,7 @@ msmsdcc_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable clocks */
|
/* Enable clocks */
|
||||||
ret = msmsdcc_enable_clocks(host, 1);
|
ret = msmsdcc_enable_clocks(host);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto clk_put;
|
goto clk_put;
|
||||||
|
|
||||||
|
@ -1263,8 +1279,7 @@ msmsdcc_probe(struct platform_device *pdev)
|
||||||
if (host->timer.function)
|
if (host->timer.function)
|
||||||
pr_info("%s: Polling status mode enabled\n", mmc_hostname(mmc));
|
pr_info("%s: Polling status mode enabled\n", mmc_hostname(mmc));
|
||||||
|
|
||||||
if (host->use_bustimer)
|
msmsdcc_disable_clocks(host, 1);
|
||||||
mod_timer(&host->busclk_timer, jiffies + BUSCLK_TIMEOUT);
|
|
||||||
return 0;
|
return 0;
|
||||||
cmd_irq_free:
|
cmd_irq_free:
|
||||||
free_irq(cmd_irqres->start, host);
|
free_irq(cmd_irqres->start, host);
|
||||||
|
@ -1272,7 +1287,7 @@ msmsdcc_probe(struct platform_device *pdev)
|
||||||
if (host->stat_irq)
|
if (host->stat_irq)
|
||||||
free_irq(host->stat_irq, host);
|
free_irq(host->stat_irq, host);
|
||||||
clk_disable:
|
clk_disable:
|
||||||
msmsdcc_enable_clocks(host, 0);
|
msmsdcc_disable_clocks(host, 0);
|
||||||
clk_put:
|
clk_put:
|
||||||
clk_put(host->clk);
|
clk_put(host->clk);
|
||||||
pclk_put:
|
pclk_put:
|
||||||
|
@ -1293,8 +1308,6 @@ msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
|
||||||
if (mmc) {
|
if (mmc) {
|
||||||
struct msmsdcc_host *host = mmc_priv(mmc);
|
struct msmsdcc_host *host = mmc_priv(mmc);
|
||||||
|
|
||||||
if (host->use_bustimer)
|
|
||||||
del_timer_sync(&host->busclk_timer);
|
|
||||||
spin_lock_irqsave(&host->lock, flags);
|
spin_lock_irqsave(&host->lock, flags);
|
||||||
if (host->stat_irq)
|
if (host->stat_irq)
|
||||||
disable_irq(host->stat_irq);
|
disable_irq(host->stat_irq);
|
||||||
|
@ -1304,10 +1317,10 @@ msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
msmsdcc_writel(host, 0, MMCIMASK0);
|
msmsdcc_writel(host, 0, MMCIMASK0);
|
||||||
|
|
||||||
if (host->clks_on)
|
|
||||||
msmsdcc_enable_clocks(host, 0);
|
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
spin_unlock_irqrestore(&host->lock, flags);
|
||||||
|
if (host->clks_on)
|
||||||
|
msmsdcc_disable_clocks(host, 0);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -1316,27 +1329,19 @@ static int
|
||||||
msmsdcc_resume(struct platform_device *dev)
|
msmsdcc_resume(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
struct mmc_host *mmc = mmc_get_drvdata(dev);
|
struct mmc_host *mmc = mmc_get_drvdata(dev);
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (mmc) {
|
if (mmc) {
|
||||||
struct msmsdcc_host *host = mmc_priv(mmc);
|
struct msmsdcc_host *host = mmc_priv(mmc);
|
||||||
|
|
||||||
spin_lock_irqsave(&host->lock, flags);
|
msmsdcc_enable_clocks(host);
|
||||||
|
|
||||||
if (!host->clks_on)
|
|
||||||
msmsdcc_enable_clocks(host, 1);
|
|
||||||
|
|
||||||
if (host->use_bustimer)
|
|
||||||
mod_timer(&host->busclk_timer, jiffies + BUSCLK_TIMEOUT);
|
|
||||||
|
|
||||||
msmsdcc_writel(host, host->saved_irq0mask, MMCIMASK0);
|
msmsdcc_writel(host, host->saved_irq0mask, MMCIMASK0);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&host->lock, flags);
|
|
||||||
|
|
||||||
if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
|
if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
|
||||||
mmc_resume_host(mmc);
|
mmc_resume_host(mmc);
|
||||||
if (host->stat_irq)
|
if (host->stat_irq)
|
||||||
enable_irq(host->stat_irq);
|
enable_irq(host->stat_irq);
|
||||||
|
msmsdcc_disable_clocks(host, 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,6 @@ struct msmsdcc_host {
|
||||||
struct clk *pclk; /* SDCC peripheral bus clock */
|
struct clk *pclk; /* SDCC peripheral bus clock */
|
||||||
unsigned int clks_on; /* set if clocks are enabled */
|
unsigned int clks_on; /* set if clocks are enabled */
|
||||||
struct timer_list busclk_timer;
|
struct timer_list busclk_timer;
|
||||||
int use_bustimer;
|
|
||||||
|
|
||||||
unsigned int eject; /* eject state */
|
unsigned int eject; /* eject state */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue