From patchwork Fri Oct 11 12:28:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 20966 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7D3CE25EA1 for ; Fri, 11 Oct 2013 12:28:49 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id qd12sf1603785ieb.10 for ; Fri, 11 Oct 2013 05:28:49 -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=uv5siWbayAk/dHQPCrXBq/ZI+ejgQ8JCZmP7R5V4YDQ=; b=V0t7UQ7LMbpv6GHc1Tv09OkLqzBQ56wZvd5xFzQHlnde0in8b51GW1hHKq5S3cl7LM RmPpHn++thHn2ppl5HkoyESF3tImNhyv6bY2tVxOcw/cuiEsl7MHZwTvRoac6XQp883x CAptBwQ9+dWwILpiy1EllIhX46GS/i/aw2qmD5aXdSxEpHd41dSWYP5fLPDUEkzhK1Nq 0ckzpKI7X26W34jTr8QAnf4m8xix1UA+w/3JngpANUmWUmNN1TrzsjDM4jqfXbuPmrCB bWSBeqAyfggYMjPl3izUy4dYoAO7edu9yoEXgZOtcHR54OD2vuUtT9RVH7/bm8I+jPst XyqA== X-Received: by 10.42.179.10 with SMTP id bo10mr8093391icb.8.1381494529025; Fri, 11 Oct 2013 05:28:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.134.74 with SMTP id pi10ls1437134qeb.35.gmail; Fri, 11 Oct 2013 05:28:48 -0700 (PDT) X-Received: by 10.221.44.136 with SMTP id ug8mr21221884vcb.13.1381494528909; Fri, 11 Oct 2013 05:28:48 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id fx4si16574887vdc.26.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Oct 2013 05:28:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 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.170; Received: by mail-vc0-f170.google.com with SMTP id lc6so2790577vcb.29 for ; Fri, 11 Oct 2013 05:28:48 -0700 (PDT) X-Gm-Message-State: ALoCoQnA8xxomwbIjE5Y52O5Osk2EWFlzjyZ1leZPz+4GydnWvFLLhmjhl1A/whr5GAGGLxjiB7R X-Received: by 10.220.15.132 with SMTP id k4mr231059vca.45.1381494528809; Fri, 11 Oct 2013 05:28:48 -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 u4csp35319vcz; Fri, 11 Oct 2013 05:28:48 -0700 (PDT) X-Received: by 10.152.3.201 with SMTP id e9mr16348918lae.24.1381494527673; Fri, 11 Oct 2013 05:28:47 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx.google.com with ESMTPS id h8si22035333lah.52.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Oct 2013 05:28:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.41 is neither permitted nor denied by best guess record for domain of ulf.hansson@linaro.org) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id ec20so3324389lab.14 for ; Fri, 11 Oct 2013 05:28:47 -0700 (PDT) X-Received: by 10.152.8.115 with SMTP id q19mr16293359laa.16.1381494527105; Fri, 11 Oct 2013 05:28:47 -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 l10sm33275873lbh.13.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Oct 2013 05:28:45 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Chris Ball Cc: "Rafael J. Wysocki" , Kevin Hilman , Alan Stern , Colin Cross , Android Kernel Team , John Stultz , Ulf Hansson Subject: [PATCH 3/4] mmc: core: Improve runtime PM support during suspend/resume for sd/mmc Date: Fri, 11 Oct 2013 14:28:17 +0200 Message-Id: <1381494498-16699-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1381494498-16699-1-git-send-email-ulf.hansson@linaro.org> References: <1381494498-16699-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.170 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: , The card device is considered as in-active after it has been suspended. To prevent any further runtime PM requests in suspend state, we then disable runtime PM. After the card device has been resumed, we shall consider it as active, like we also do after a probe sequence. When resumed, we can safely enable runtime PM again. This will make sure the PM core can request the card device to go to in-active state after a resume has been completed. Previously we had to wait for new pm_runtime_get->pm_runtime_put cycle to be executed. Additionally, once a resume has been carried out, update the last busy mark. At the moment this will have no effect but if the PM core will respect autosuspend enabled devices, when it directly triggers a runtime_suspend from a runtime_idle, it will mean the card device will be scheduled for a delayed runtime_suspend instead of done immediately. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 38 ++++++++++++++++++++++++++++++-------- drivers/mmc/core/sd.c | 45 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 907f0a0..1e29dbc 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -1509,20 +1510,26 @@ out: } /* - * Suspend callback from host. + * Suspend callback */ static int mmc_suspend(struct mmc_host *host) { - return _mmc_suspend(host, true); + int err; + + err = _mmc_suspend(host, true); + if (!err) { + pm_runtime_disable(&host->card->dev); + pm_runtime_set_suspended(&host->card->dev); + } + + return err; } /* - * Resume callback from host. - * * This function tries to determine if the same card is still present * and, if so, restore all state to it. */ -static int mmc_resume(struct mmc_host *host) +static int _mmc_resume(struct mmc_host *host) { int err = 0; @@ -1557,7 +1564,7 @@ static int mmc_shutdown(struct mmc_host *host) */ if (mmc_can_poweroff_notify(host->card) && !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)) - err = mmc_resume(host); + err = _mmc_resume(host); if (!err) err = _mmc_suspend(host, false); @@ -1566,6 +1573,21 @@ static int mmc_shutdown(struct mmc_host *host) } /* + * Callback for resume. + */ +static int mmc_resume(struct mmc_host *host) +{ + int err; + + err = _mmc_resume(host); + pm_runtime_set_active(&host->card->dev); + pm_runtime_mark_last_busy(&host->card->dev); + pm_runtime_enable(&host->card->dev); + + return err; +} + +/* * Callback for runtime_suspend. */ static int mmc_runtime_suspend(struct mmc_host *host) @@ -1575,7 +1597,7 @@ static int mmc_runtime_suspend(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_suspend(host); + err = _mmc_suspend(host, true); if (err) pr_err("%s: error %d doing aggessive suspend\n", mmc_hostname(host), err); @@ -1593,7 +1615,7 @@ static int mmc_runtime_resume(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_resume(host); + err = _mmc_resume(host); if (err) pr_err("%s: error %d doing aggessive resume\n", mmc_hostname(host), err); diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 2287ceb..57940a8 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -1064,10 +1065,7 @@ static void mmc_sd_detect(struct mmc_host *host) } } -/* - * Suspend callback from host. - */ -static int mmc_sd_suspend(struct mmc_host *host) +static int _mmc_sd_suspend(struct mmc_host *host) { int err = 0; @@ -1093,12 +1091,26 @@ out: } /* - * Resume callback from host. - * + * Callback for suspend + */ +static int mmc_sd_suspend(struct mmc_host *host) +{ + int err; + + err = _mmc_sd_suspend(host); + if (!err) { + pm_runtime_disable(&host->card->dev); + pm_runtime_set_suspended(&host->card->dev); + } + + return err; +} + +/* * This function tries to determine if the same card is still present * and, if so, restore all state to it. */ -static int mmc_sd_resume(struct mmc_host *host) +static int _mmc_sd_resume(struct mmc_host *host) { int err = 0; @@ -1121,6 +1133,21 @@ out: } /* + * Callback for resume + */ +static int mmc_sd_resume(struct mmc_host *host) +{ + int err; + + err = _mmc_sd_resume(host); + pm_runtime_set_active(&host->card->dev); + pm_runtime_mark_last_busy(&host->card->dev); + pm_runtime_enable(&host->card->dev); + + return err; +} + +/* * Callback for runtime_suspend. */ static int mmc_sd_runtime_suspend(struct mmc_host *host) @@ -1130,7 +1157,7 @@ static int mmc_sd_runtime_suspend(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_sd_suspend(host); + err = _mmc_sd_suspend(host); if (err) pr_err("%s: error %d doing aggessive suspend\n", mmc_hostname(host), err); @@ -1148,7 +1175,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = mmc_sd_resume(host); + err = _mmc_sd_resume(host); if (err) pr_err("%s: error %d doing aggessive resume\n", mmc_hostname(host), err);