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: 4408741 Return-Path: X-Original-To: patchwork-linux-mmc@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 429F99F37C for ; Tue, 24 Jun 2014 13:59:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45CC22034B for ; Tue, 24 Jun 2014 13:59:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64BE120170 for ; Tue, 24 Jun 2014 13:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753499AbaFXN5t (ORCPT ); Tue, 24 Jun 2014 09:57:49 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:19790 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751984AbaFXN5s (ORCPT ); Tue, 24 Jun 2014 09:57:48 -0400 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>; 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Kukjin Kim , Marek Szyprowski , Tomasz Figa , Tomasz Figa , Ben Dooks , Chris Ball , Ulf Hansson , linux-mmc@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== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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);