lkml.org 
[lkml]   [2013]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 2/7] mmc: atmel-mci: prepare clk before calling enable
On Tue, Jul 16, 2013 at 05:06:48PM +0200, Boris BREZILLON wrote:
> @@ -389,9 +391,13 @@ static int atmci_regs_show(struct seq_file *s, void *v)
> * consistent.
> */
> spin_lock_bh(&host->lock);
> - clk_enable(host->mck);
> + ret = clk_prepare_enable(host->mck);
> + if (ret) {
> + spin_unlock_bh(&host->lock);
> + goto out;
> + }

NAK. This is buggy. clk_prepare() can sleep. Calling clk_prepare()
even via clk_prepare_enable() is a blatent bug.

> memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE);
> - clk_disable(host->mck);
> + clk_disable_unprepare(host->mck);
> spin_unlock_bh(&host->lock);

Now, given that the CLK API counts enables/disables, having the spin lock
around the clk API calls is utterly pointless. This should be:

ret = clk_prepare_enable(host->mck);
if (ret)
goto out;

spin_lock_bh(&host->lock);
memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE);
spin_unlock_bh(&host->lock);

clk_disable_unprepare(host->mclk);

or, if you really need to have the clock enabled/disabled within the
spinlock (very very very unlikely):

ret = clk_prepare(host->mck);
if (ret)
goto out;

spin_lock_bh(&host->lock);
ret = clk_enable(host->mck);
if (ret == 0) {
memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE);
clk_disable(host->mck);
}
spin_unlock_bh(&host->lock);

clk_unprepare(host->mclk);
if (ret)
goto out;

> @@ -1279,7 +1286,7 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>
> spin_lock_bh(&host->lock);
> if (!host->mode_reg) {
> - clk_enable(host->mck);
> + clk_prepare_enable(host->mck);

Again, buggy - calling clk_prepare beneath a spinlock is illegal.


\
 
 \ /
  Last update: 2013-07-16 21:21    [W:0.115 / U:35.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site