Hi Linus, On Wed, Nov 3, 2010 at 11:22 AM, Linus Walleij <linus.walleij@xxxxxxxxxxxxxx> wrote: ... > +static void mmc_host_clk_gate_delayed(struct mmc_host *host) > +{ > + unsigned long tick_ns; > + unsigned long freq = host->ios.clock; > + unsigned long flags; > + int users; > + > + if (!freq) { > + pr_err("%s: frequency set to 0 in disable function, " > + "this means the clock is already disabled.\n", > + mmc_hostname(host)); > + return; > + } > + /* > + * New requests may have appeared while we were scheduling, > + * then there is no reason to delay the check before > + * clk_disable(). > + */ > + spin_lock_irqsave(&host->clk_lock, flags); > + users = host->clk_requests; > + /* > + * Delay n bus cycles (at least 8 from MMC spec) before attempting > + * to disable the MCI block clock. The reference count > + * may have gone up again after this delay due to > + * rescheduling! > + */ > + if (!users) { > + spin_unlock_irqrestore(&host->clk_lock, flags); > + tick_ns = DIV_ROUND_UP(1000000000, freq); > + ndelay(host->clk_delay * tick_ns); > + } else { > + /* New users appeared while waiting for this work */ > + host->clk_pending_gate = false; > + spin_unlock_irqrestore(&host->clk_lock, flags); > + return; > + } > + spin_lock_irqsave(&host->clk_lock, flags); > + if (!host->clk_requests) { > + spin_unlock_irqrestore(&host->clk_lock, flags); What if mmc_host_clk_ungate() is invoked (and completely executes) at this point (as a result of a new mmc request) ? > + /* this will set host->ios.clock to 0 */ > + mmc_gate_clock(host); Will this clock gating not disrupt that new mmc request ? Or am I missing something ? > + spin_lock_irqsave(&host->clk_lock, flags); > + pr_debug("%s: gated MCI clock\n", > + mmc_hostname(host)); > + } > + host->clk_pending_gate = false; What is clk_pending_gate used for (I can only see it being assigned values) ? Thanks, Ohad. (PS sorry for the belated posting of these questions) -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html