From patchwork Tue Nov 16 16:57:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 328712 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAGGvDfJ032524 for ; Tue, 16 Nov 2010 16:57:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754874Ab0KPQ5M (ORCPT ); Tue, 16 Nov 2010 11:57:12 -0500 Received: from eu1sys200aog104.obsmtp.com ([207.126.144.117]:40620 "EHLO eu1sys200aog104.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754277Ab0KPQ5M (ORCPT ); Tue, 16 Nov 2010 11:57:12 -0500 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKTOK34M80aCk/agpjM9dAH9lg6fMnodUy@postini.com; Tue, 16 Nov 2010 16:57:11 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3DF6978; Tue, 16 Nov 2010 16:57:03 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0F5AE2C3F; Tue, 16 Nov 2010 16:57:03 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 805AEA8072; Tue, 16 Nov 2010 17:56:56 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.2.254.0; Tue, 16 Nov 2010 17:57:02 +0100 From: Linus Walleij To: , Chris Ball Cc: Linus Walleij Subject: [PATCH 3/3] mmc: protect some gating variables Date: Tue, 16 Nov 2010 17:57:00 +0100 Message-ID: <1289926620-14085-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.6.3.3 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Nov 2010 16:57:13 +0000 (UTC) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 8afc620..c5ae489 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -617,15 +617,8 @@ static inline void mmc_set_ios(struct mmc_host *host) ios->power_mode, ios->chip_select, ios->vdd, ios->bus_width, ios->timing); -#ifdef CONFIG_MMC_CLKGATE - /* - * We've been given a new frequency while the clock is gated, - * so make sure we regard this as ungating it. - */ - if (ios->clock > 0 && host->clk_gated) - host->clk_gated = false; -#endif - + if (ios->clock > 0) + mmc_set_ungated(host); host->ops->set_ios(host, ios); } @@ -659,9 +652,13 @@ void mmc_set_clock(struct mmc_host *host, unsigned int hz) */ void mmc_gate_clock(struct mmc_host *host) { + unsigned long flags; + + spin_lock_irqsave(&host->clk_lock, flags); host->clk_old = host->ios.clock; host->ios.clock = 0; host->clk_gated = true; + spin_unlock_irqrestore(&host->clk_lock, flags); mmc_set_ios(host); } @@ -680,9 +677,27 @@ void mmc_ungate_clock(struct mmc_host *host) */ if (host->clk_old) { BUG_ON(host->ios.clock); + /* This call will also set host->clk_gated to false */ mmc_set_clock(host, host->clk_old); } +} + +void mmc_set_ungated(struct mmc_host *host) +{ + unsigned long flags; + + /* + * We've been given a new frequency while the clock is gated, + * so make sure we regard this as ungating it. + */ + spin_lock_irqsave(&host->clk_lock, flags); host->clk_gated = false; + spin_unlock_irqrestore(&host->clk_lock, flags); +} + +#else +void mmc_set_ungated(struct mmc_host *host) +{ } #endif diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 9972808..026c975 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -35,6 +35,7 @@ void mmc_set_chip_select(struct mmc_host *host, int mode); void mmc_set_clock(struct mmc_host *host, unsigned int hz); void mmc_gate_clock(struct mmc_host *host); void mmc_ungate_clock(struct mmc_host *host); +void mmc_set_ungated(struct mmc_host *host); void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); void mmc_set_bus_width(struct mmc_host *host, unsigned int width); void mmc_set_bus_width_ddr(struct mmc_host *host, unsigned int width,