From patchwork Wed Oct 2 08:30:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 20743 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 46C4725E05 for ; Wed, 2 Oct 2013 08:31:09 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf992818vbg.11 for ; Wed, 02 Oct 2013 01:31:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=nNbWwf3RMVXmQihzBLnY/AuNf1/lqARWOWanU0fwan0=; b=HODuQ0Xjtnz8WG24iQ/s342Kcfhtz9bytNTzVxU7W5UrrGe1scQam+FZ9BI9yx5G0B 5/RBnsSJ2Coiswek7540WgqxFN1oztZhsvC2v3201WKgEeAi4pZUHIQr5NgwBxjKb8jE 9yTiXx6y88+9BFq7tt0QGkDLfa8TDUkDpoL4RTnDvFgBv9Kb+ahzQgTMney7g+aeLixa Spg71mXsrThr0anvAk8NGZZYCbgb079IukBkriw1APN142H7907nvMiWuKR9OsLe9/tJ hUDHq+yNWdgsB57rJhAk60XcMu4eR0B+GW0ELrsLsjZOQCd6JC8G9vH2rUkTLePiN5GY k6xQ== X-Received: by 10.236.111.73 with SMTP id v49mr1153216yhg.46.1380702669124; Wed, 02 Oct 2013 01:31:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.109.226 with SMTP id hv2ls376519qeb.22.gmail; Wed, 02 Oct 2013 01:31:09 -0700 (PDT) X-Received: by 10.58.137.167 with SMTP id qj7mr896065veb.1.1380702668980; Wed, 02 Oct 2013 01:31:08 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id rl1si93458vcb.74.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id ij15so301170vcb.30 for ; Wed, 02 Oct 2013 01:31:08 -0700 (PDT) X-Gm-Message-State: ALoCoQleAi9cGkWd2Rq3ZPEjOCJIr/hmDvaMAwL2gG2iG+ruZrZS0VQ1U9P5jhzdIiCdN4YNC3CO X-Received: by 10.52.113.99 with SMTP id ix3mr773858vdb.22.1380702668877; Wed, 02 Oct 2013 01:31:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp79367vcz; Wed, 2 Oct 2013 01:31:08 -0700 (PDT) X-Received: by 10.152.228.130 with SMTP id si2mr989501lac.32.1380702667586; Wed, 02 Oct 2013 01:31:07 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) by mx.google.com with ESMTPS id jk7si660210lbc.10.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.176 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id y6so452665lbh.7 for ; Wed, 02 Oct 2013 01:31:07 -0700 (PDT) X-Received: by 10.112.157.67 with SMTP id wk3mr794155lbb.32.1380702666962; Wed, 02 Oct 2013 01:31:06 -0700 (PDT) Received: from linaro-ulf.lan (90-231-160-185-no158.tbcn.telia.com. [90.231.160.185]) by mx.google.com with ESMTPSA id e4sm890041lba.15.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 01:31:06 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: Ulf Hansson , Guennadi Liakhovetski Subject: [PATCH 4/7] mmc: sh_mmcif: Use runtime PM to keep resourses active during I/O Date: Wed, 2 Oct 2013 10:30:48 +0200 Message-Id: <1380702651-13389-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1380702651-13389-1-git-send-email-ulf.hansson@linaro.org> References: <1380702651-13389-1-git-send-email-ulf.hansson@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , While I/O operations are ongoing, make sure the runtime PM resourses are kept active. When returning the resourses, utilize the runtime PM autosuspend feature with a default timeout set to 50 ms. The reason for chosing a 50 ms timeout is to make sure we are able to handle clock gating in a future possible runtime suspend callback. According to the (e)MMC/SD/SDIO specification the clock must be maintained for a minimum numbers of clock cycles even after responses has been received. 50 ms will cover all cases. Additionally, 50 ms has for other host drivers seemed reasonable, to prevent bringing the runtime resourses up and down between each and every request. Cc: Guennadi Liakhovetski Signed-off-by: Ulf Hansson --- drivers/mmc/host/sh_mmcif.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index d032b08..f4532dc 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -959,6 +959,8 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq) host->mrq = mrq; + pm_runtime_get_sync(mmc_dev(mmc)); + sh_mmcif_start_cmd(host, mrq); } @@ -1000,6 +1002,8 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host->state = STATE_IOS; spin_unlock_irqrestore(&host->lock, flags); + pm_runtime_get_sync(mmc_dev(mmc)); + if (ios->power_mode == MMC_POWER_UP) { if (!host->card_present) { /* See if we also get DMA */ @@ -1017,20 +1021,18 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) } } if (host->power) { - pm_runtime_put_sync(&host->pd->dev); clk_disable_unprepare(host->hclk); host->power = false; if (ios->power_mode == MMC_POWER_OFF) sh_mmcif_set_power(host, ios); } host->state = STATE_IDLE; - return; + goto ret; } if (ios->clock) { if (!host->power) { sh_mmcif_clk_update(host); - pm_runtime_get_sync(&host->pd->dev); host->power = true; sh_mmcif_sync_reset(host); } @@ -1040,6 +1042,9 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host->timing = ios->timing; host->bus_width = ios->bus_width; host->state = STATE_IDLE; +ret: + pm_runtime_mark_last_busy(mmc_dev(mmc)); + pm_runtime_put_autosuspend(mmc_dev(mmc)); } static int sh_mmcif_get_cd(struct mmc_host *mmc) @@ -1253,6 +1258,9 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) mutex_unlock(&host->thread_lock); + pm_runtime_mark_last_busy(mmc_dev(host->mmc)); + pm_runtime_put_autosuspend(mmc_dev(host->mmc)); + return IRQ_HANDLED; } @@ -1341,6 +1349,9 @@ static void mmcif_timeout_work(struct work_struct *work) host->wait_for = MMCIF_WAIT_FOR_REQUEST; host->mrq = NULL; mmc_request_done(host->mmc, mrq); + + pm_runtime_mark_last_busy(mmc_dev(host->mmc)); + pm_runtime_put_autosuspend(mmc_dev(host->mmc)); } static void sh_mmcif_init_ocr(struct sh_mmcif_host *host) @@ -1421,23 +1432,18 @@ static int sh_mmcif_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); - pm_runtime_enable(&pdev->dev); host->power = false; host->hclk = clk_get(&pdev->dev, NULL); if (IS_ERR(host->hclk)) { ret = PTR_ERR(host->hclk); dev_err(&pdev->dev, "cannot get clock: %d\n", ret); - goto eclkget; + goto eofparse; } ret = sh_mmcif_clk_update(host); if (ret < 0) goto eclkupdate; - ret = pm_runtime_resume(&pdev->dev); - if (ret < 0) - goto eresume; - INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work); sh_mmcif_sync_reset(host); @@ -1466,6 +1472,12 @@ static int sh_mmcif_probe(struct platform_device *pdev) mutex_init(&host->thread_lock); + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 50); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + clk_disable_unprepare(host->hclk); ret = mmc_add_host(mmc); if (ret < 0) @@ -1476,22 +1488,24 @@ static int sh_mmcif_probe(struct platform_device *pdev) dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION); dev_dbg(&pdev->dev, "chip ver H'%04x\n", sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff); + + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + return ret; emmcaddh: + pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); erqcd: if (irq[1] >= 0) free_irq(irq[1], host); ereqirq1: free_irq(irq[0], host); ereqirq0: - pm_runtime_suspend(&pdev->dev); -eresume: clk_disable_unprepare(host->hclk); eclkupdate: clk_put(host->hclk); -eclkget: - pm_runtime_disable(&pdev->dev); eofparse: mmc_free_host(mmc); ealloch: @@ -1532,8 +1546,8 @@ static int sh_mmcif_remove(struct platform_device *pdev) clk_disable_unprepare(host->hclk); mmc_free_host(host->mmc); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); return 0; }