From patchwork Tue Apr 16 10:55:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 16157 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-ye0-f197.google.com (mail-ye0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9170823A3E for ; Tue, 16 Apr 2013 10:56:33 +0000 (UTC) Received: by mail-ye0-f197.google.com with SMTP id q1sf491382yen.8 for ; Tue, 16 Apr 2013 03:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :from:to:cc:subject:date:message-id:x-mailer:mime-version :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=vHlAXcgt1i7Jkw1vfGJe06pc25Jh3Byzl0v/jz32pS8=; b=n60ziksRcrt4EiXOHDnj6r5SVZHqCrvSBoEqy0C+LCQ6NTirjBCr6qQ0FP+FkzvTtf fvbnVBnQKPmb9dx8DhvJMQAL56S2wu0fZU2eBDNtlWVwm+gjvjursE2igFMX5GXnNvVr suUtSdpPR55LflBFy7Zgbyk+Q8gOEJ0FcZ4XRQ8JiPB7TunSKPU+28nHNVZakFd5PNG6 ZPrrYW98zjZDcuWwfZO59FlFUppWCET/ZJ9aV89HTPqtRSX3DlLcmWUglMnUvPE9ksYl cMoBo/Kw9j75rVaGrwSS6YBp355SQTkTee6zX8+aBJJVVtQAw/n2DhC9Bf5lFscvrJuA XFjw== X-Received: by 10.224.65.6 with SMTP id g6mr1453718qai.4.1366109760741; Tue, 16 Apr 2013 03:56:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.96.2 with SMTP id do2ls201096qeb.62.gmail; Tue, 16 Apr 2013 03:56:00 -0700 (PDT) X-Received: by 10.52.25.8 with SMTP id y8mr909441vdf.88.1366109760365; Tue, 16 Apr 2013 03:56:00 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id sa4si861244vdc.62.2013.04.16.03.56.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Apr 2013 03:56:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 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.177; Received: by mail-vc0-f177.google.com with SMTP id hr11so255986vcb.8 for ; Tue, 16 Apr 2013 03:56:00 -0700 (PDT) X-Received: by 10.220.242.73 with SMTP id lh9mr1062288vcb.49.1366109760020; Tue, 16 Apr 2013 03:56:00 -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.58.127.98 with SMTP id nf2csp18466veb; Tue, 16 Apr 2013 03:55:59 -0700 (PDT) X-Received: by 10.15.75.70 with SMTP id k46mr5343381eey.4.1366109758229; Tue, 16 Apr 2013 03:55:58 -0700 (PDT) Received: from eu1sys200aog123.obsmtp.com (eu1sys200aog123.obsmtp.com [207.126.144.155]) by mx.google.com with SMTP id u3si1868178eeg.133.2013.04.16.03.55.53 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Apr 2013 03:55:58 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.155 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.155; Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob123.postini.com ([207.126.147.11]) with SMTP ID DSNKUW0uM5V9Afsa876Pxd5Ir6U9GyJjjM+Q@postini.com; Tue, 16 Apr 2013 10:55:58 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A8AE7FE; Tue, 16 Apr 2013 10:55:45 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3D5FD4DC2; Tue, 16 Apr 2013 10:55:41 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 3F523A807E; Tue, 16 Apr 2013 12:55:40 +0200 (CEST) Received: from steludxu1397.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.279.5; Tue, 16 Apr 2013 12:55:44 +0200 From: Ulf Hansson To: , Chris Ball Cc: Ulf Hansson , Maya Erez , Subhash Jadavani , Arnd Bergmann , Kevin Liu , Adrian Hunter , Daniel Drake , Ohad Ben-Cohen Subject: [RESEND PATCH V3 4/4] mmc: core: Support aggressive power management for (e)MMC/SD Date: Tue, 16 Apr 2013 12:55:35 +0200 Message-ID: <1366109735-18178-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkm9u9mdgybLf6YYFH0Hf1kgjgdg6VE6oe5UgmbEWQQjeXG/dgOEfxDl7cMu9VH/csrBFwy X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.177 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: , From: Ulf Hansson Aggressive power management is suitable when saving power is essential. At request inactivity timeout, aka pm runtime autosuspend timeout, the card will be suspended. Once a new request arrives, the card will be re-initalized and thus the first request will suffer from a latency. This latency is card-specific, experiments has shown in general that SD-cards has quite poor initialization time, around 300ms-1100ms. eMMC is not surprisingly far better but still a couple of hundreds of ms has been observed. Except for the request latency, it is important to know that suspending the card will also prevent the card from executing internal house-keeping operations in idle mode. This could mean degradation in performance. To use this feature make sure the request inactivity timeout is chosen carefully. This has not been done as a part of this patch. Enable this feature by using host cap MMC_CAP_AGGRESSIVE_PM and by setting CONFIG_MMC_UNSAFE_RESUME. Signed-off-by: Ulf Hansson Cc: Maya Erez Cc: Subhash Jadavani Cc: Arnd Bergmann Cc: Kevin Liu Cc: Adrian Hunter Cc: Daniel Drake Cc: Ohad Ben-Cohen --- drivers/mmc/core/mmc.c | 43 +++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/core/sd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/host.h | 2 +- 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index bf19058..8dfbc84 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1454,6 +1454,47 @@ static int mmc_resume(struct mmc_host *host) return err; } + +/* + * Callback for runtime_suspend. + */ +static int mmc_runtime_suspend(struct mmc_host *host) +{ + int err; + + if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) + return 0; + + err = mmc_suspend(host); + if (err) { + pr_err("%s: error %d doing aggessive suspend\n", + mmc_hostname(host), err); + return err; + } + + mmc_power_off(host); + return err; +} + +/* + * Callback for runtime_resume. + */ +static int mmc_runtime_resume(struct mmc_host *host) +{ + int err; + + if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) + return 0; + + mmc_power_up(host); + err = mmc_resume(host); + if (err) + pr_err("%s: error %d doing aggessive resume\n", + mmc_hostname(host), err); + + return err; +} + static int mmc_power_restore(struct mmc_host *host) { int ret; @@ -1514,6 +1555,8 @@ static const struct mmc_bus_ops mmc_ops_unsafe = { .detect = mmc_detect, .suspend = mmc_suspend, .resume = mmc_resume, + .runtime_suspend = mmc_runtime_suspend, + .runtime_resume = mmc_runtime_resume, .power_restore = mmc_power_restore, .alive = mmc_alive, }; diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 30387d6..e0458f9 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1095,6 +1095,46 @@ static int mmc_sd_resume(struct mmc_host *host) return err; } +/* + * Callback for runtime_suspend. + */ +static int mmc_sd_runtime_suspend(struct mmc_host *host) +{ + int err; + + if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) + return 0; + + err = mmc_sd_suspend(host); + if (err) { + pr_err("%s: error %d doing aggessive suspend\n", + mmc_hostname(host), err); + return err; + } + + mmc_power_off(host); + return err; +} + +/* + * Callback for runtime_resume. + */ +static int mmc_sd_runtime_resume(struct mmc_host *host) +{ + int err; + + if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) + return 0; + + mmc_power_up(host); + err = mmc_sd_resume(host); + if (err) + pr_err("%s: error %d doing aggessive resume\n", + mmc_hostname(host), err); + + return err; +} + static int mmc_sd_power_restore(struct mmc_host *host) { int ret; @@ -1119,6 +1159,8 @@ static const struct mmc_bus_ops mmc_sd_ops = { static const struct mmc_bus_ops mmc_sd_ops_unsafe = { .remove = mmc_sd_remove, .detect = mmc_sd_detect, + .runtime_suspend = mmc_sd_runtime_suspend, + .runtime_resume = mmc_sd_runtime_resume, .suspend = mmc_sd_suspend, .resume = mmc_sd_resume, .power_restore = mmc_sd_power_restore, diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 17d7148..cec6684 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -239,7 +239,7 @@ struct mmc_host { #define MMC_CAP_SPI (1 << 4) /* Talks only SPI protocols */ #define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */ #define MMC_CAP_8_BIT_DATA (1 << 6) /* Can the host do 8 bit transfers */ - +#define MMC_CAP_AGGRESSIVE_PM (1 << 7) /* Suspend (e)MMC/SD at idle */ #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */ #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */ #define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */