From patchwork Tue Jun 24 13:57:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 4408831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E541B9F402 for ; Tue, 24 Jun 2014 14:00:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC2D720379 for ; Tue, 24 Jun 2014 14:00:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 2B91620374 for ; Tue, 24 Jun 2014 14:00:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WzRFO-0004cp-Hf; Tue, 24 Jun 2014 13:58:54 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WzREj-000488-6A for linux-arm-kernel@lists.infradead.org; Tue, 24 Jun 2014 13:58:15 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N7O003MDERUG640@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Tue, 24 Jun 2014 14:57:30 +0100 (BST) X-AuditID: cbfec7f4-b7fac6d000006cfe-e6-53a983d9ce65 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 3B.19.27902.9D389A35; Tue, 24 Jun 2014 14:57:45 +0100 (BST) Received: from AMDC1227.digital.local ([106.116.147.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N7O005SHES5FQ50@eusync3.samsung.com>; Tue, 24 Jun 2014 14:57:45 +0100 (BST) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/6] mmc: sdhci-s3c: Fix local I/O clock gating Date: Tue, 24 Jun 2014 15:57:10 +0200 Message-id: <1403618235-19353-2-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.9.3 In-reply-to: <1403618235-19353-1-git-send-email-t.figa@samsung.com> References: <1403618235-19353-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t/xq7o3m1cGGxx/x2Qxad0BJosJl7cz WvQuuMpmsenxNVaLy7vmsFkc+d/PaDHj/D4mi7VH7rJbrJ/xmsVi1a4/jBbH14Y7cHv8XfWC 2WPnrLvsHneu7WHz2Lyk3uPGq4VMHn1bVjF6fN4kF8AexWWTkpqTWZZapG+XwJXxoP0pa8Fi /orlk06yNTBe4Oli5OSQEDCR+Hx9PROELSZx4d56ti5GLg4hgaWMEi+m/WCEcPqYJOZMaGAB qWITUJP43PCIDcQWEVCV+Ny2gB2kiFngJZPE6i3tYEXCAvYSn252MYLYLEBF137+A1vBK+Ak MfnWO2aIdXISvdvegNmcAs4SO9u3sYLYQkA1/082MU1g5F3AyLCKUTS1NLmgOCk911CvODG3 uDQvXS85P3cTIyQgv+xgXHzM6hCjAAejEg/vhV0rgoVYE8uKK3MPMUpwMCuJ8N6oWRksxJuS WFmVWpQfX1Sak1p8iJGJg1OqgXFV6L6bM7+81g7q4+DMfBZoFPhd6ndjueoZv44lZgumWWft urR79cuUELPpKVl7vnh/cquPb/ngsTJkt+7PCjlWpsLvN6YJlFTtFJko0Mp5OWya7ssfGk3R s6ZM+lW5Vj5FtiNqCuOERWqxve7X6j5dVHGM27j735v6vuZSE2bnu/O89/+uuq7EUpyRaKjF XFScCADB/KM3JgIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140624_065813_462172_AC5C4CB2 X-CRM114-Status: GOOD ( 12.07 ) X-Spam-Score: -5.0 (-----) Cc: Ulf Hansson , Kukjin Kim , linux-mmc@vger.kernel.org, Tomasz Figa , Chris Ball , Tomasz Figa , linux-kernel@vger.kernel.org, Ben Dooks , linux-arm-kernel@lists.infradead.org, Marek Szyprowski X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, 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 For internal card detection mechanism it is required that the local I/O clock is always running. However while current implementation accounts for this, it does so incorrectly leading to race conditions and warnings about unbalanced clock disables. This patch fixes it by inverting the logic, which now increases local I/O clock enable count when internal card detect is used, instead of decreasing it otherwise. Signed-off-by: Tomasz Figa Cc: Ben Dooks Cc: Chris Ball Cc: Ulf Hansson Cc: linux-mmc@vger.kernel.org Acked-by: Jaehoon Chung --- drivers/mmc/host/sdhci-s3c.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index fa5954a..1795e1f 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -487,8 +487,13 @@ static int sdhci_s3c_probe(struct platform_device *pdev) goto err_pdata_io_clk; } - /* enable the local io clock and keep it running for the moment. */ - clk_prepare_enable(sc->clk_io); + /* + * Keep local I/O clock enabled for internal card detect pin + * or runtime PM is disabled. + */ + if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL + || !IS_ENABLED(CONFIG_PM_RUNTIME)) + clk_prepare_enable(sc->clk_io); for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) { char name[14]; @@ -611,15 +616,13 @@ static int sdhci_s3c_probe(struct platform_device *pdev) goto err_req_regs; } -#ifdef CONFIG_PM_RUNTIME - if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) - clk_disable_unprepare(sc->clk_io); -#endif return 0; err_req_regs: err_no_busclks: - clk_disable_unprepare(sc->clk_io); + if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL + || !IS_ENABLED(CONFIG_PM_RUNTIME)) + clk_disable_unprepare(sc->clk_io); err_pdata_io_clk: sdhci_free_host(host);