From patchwork Sat Jan 11 21:39:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3470571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 27A1EC02DC for ; Sat, 11 Jan 2014 21:40:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5EDE220127 for ; Sat, 11 Jan 2014 21:40:00 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D5C620123 for ; Sat, 11 Jan 2014 21:39:59 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W26HX-0006ih-7g; Sat, 11 Jan 2014 21:39:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W26HU-0001w3-69; Sat, 11 Jan 2014 21:39:48 +0000 Received: from mail-ea0-x234.google.com ([2a00:1450:4013:c01::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W26HP-0001ul-1r for linux-arm-kernel@lists.infradead.org; Sat, 11 Jan 2014 21:39:45 +0000 Received: by mail-ea0-f180.google.com with SMTP id f15so2633764eak.25 for ; Sat, 11 Jan 2014 13:39:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lNE3AY8VDv4KLe9YmXw10NqeLddUJAdmDXeQJ4cW0kE=; b=gjAcJ/SxgKiI6gdQmPGw0MfRrzD0AP7PsJBDKs5FhaPxcTm5CgX2ndO3wuMPfJvMmW kzwR9Rnqq3R3ybJI07HU1ISL8ZTP9rroIX9/Oz/PlqjWTAdoIXiZ3mQxB3waFW0eSutr rW4fvk9zcioR79ojZmcLJFKfDCi5xQcFB/6Q10TR99QQfUnXlug3hSFt2oOe5gVfLOM2 5vQHxZWfj4fUJf+bfbv146vq/nyQ/aligtVkeVE/Kt6puUUn7sphXMddm2d5cITUXaQ1 MPqA4K8EqQArNmeGh1xP/d3GacNaUE9GFyo9qaIwK2l7GyUpAvNjowGJKEZmrCur4gkB So9g== X-Received: by 10.15.91.3 with SMTP id r3mr18223297eez.18.1389476361737; Sat, 11 Jan 2014 13:39:21 -0800 (PST) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id p45sm26014591eeg.1.2014.01.11.13.39.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jan 2014 13:39:21 -0800 (PST) From: Tomasz Figa To: linux-mmc@vger.kernel.org Subject: [PATCH 2/6] mmc: sdhci-s3c: Cache bus clock rates Date: Sat, 11 Jan 2014 22:39:02 +0100 Message-Id: <1389476346-20396-3-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389476346-20396-1-git-send-email-tomasz.figa@gmail.com> References: <1389476346-20396-1-git-send-email-tomasz.figa@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140111_163944_079830_B3224215 X-CRM114-Status: GOOD ( 10.74 ) X-Spam-Score: -2.0 (--) Cc: linux-samsung-soc@vger.kernel.org, Seungwon Jeon , Chris Ball , Tomasz Figa , Jaehoon Chung , Ben Dooks , linux-arm-kernel@lists.infradead.org, Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To fix scheduling while atomic happening in sdhci_s3c_set_clock() caused by calling clk_get_rate() that might sleep, this patch modifies the driver to cache rates of all bus clocks at probe time and then only use those cache values. Signed-off-by: Tomasz Figa --- drivers/mmc/host/sdhci-s3c.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 52770d5..9b78391 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -57,6 +57,7 @@ struct sdhci_s3c { struct clk *clk_io; struct clk *clk_bus[MAX_BUS_CLK]; + unsigned long clk_rates[MAX_BUS_CLK]; }; /** @@ -158,7 +159,7 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, return wanted - rate; } - rate = clk_get_rate(clksrc); + rate = ourhost->clk_rates[src]; for (shift = 0; shift < 8; ++shift) { if ((rate >> shift) <= wanted) @@ -215,7 +216,7 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock) writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL); ourhost->cur_clk = best_src; - host->max_clk = clk_get_rate(clk); + host->max_clk = ourhost->clk_rates[best_src]; ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2); ctrl &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK; @@ -583,8 +584,10 @@ static int sdhci_s3c_probe(struct platform_device *pdev) */ sc->cur_clk = ptr; + sc->clk_rates[ptr] = clk_get_rate(sc->clk_bus[ptr]); + dev_info(dev, "clock source %d: %s (%ld Hz)\n", - ptr, name, clk_get_rate(clk)); + ptr, name, sc->clk_rates[ptr]); } if (clks == 0) {