From patchwork Mon Jun 10 15:03:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 17736 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B70FC2397B for ; Mon, 10 Jun 2013 15:04:16 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id ha12sf1613257vcb.4 for ; Mon, 10 Jun 2013 08:04:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :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=eUygUUi9zEF6Pc+Q64ZEfIcmWunyl1/5qZXqKdWXPN4=; b=f4H+FoaZTpx+NKb/3Tf7YxghYc6uKzWI0yq5VqoDsCAGiQlsGA0Y45LaiX9kHwe8bk t40NDNXocJAzmUPt8wx5+KCHU+SS8JmEQuKO2nUPM7Z/KnjhyuAHc9qRcEp7qon6RLmL z1EtUCCoSjVyNM5CMQGS5bPcmtrgz+cDzwdCx2ahZPcQZGwjCplgFlWb4p3iFj9voIze n99iumVOxgkKM6+QaSSE8Jav61IivR7Iis7cq+cpA9MBoLCPTB+bQ/tZxgbbhVIrFBzm v+3tsLfLAidZQ8O7WMPwKhMUJ1KmMn4Eu1Poxe2iPbayT/qupo3izwl0iudZ/AKh0Pci 9XIg== X-Received: by 10.58.128.196 with SMTP id nq4mr1541795veb.25.1370876656538; Mon, 10 Jun 2013 08:04:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.138 with SMTP id u10ls1707591qef.75.gmail; Mon, 10 Jun 2013 08:04:16 -0700 (PDT) X-Received: by 10.52.164.98 with SMTP id yp2mr4958902vdb.111.1370876656265; Mon, 10 Jun 2013 08:04:16 -0700 (PDT) Received: from mail-ve0-x22d.google.com (mail-ve0-x22d.google.com [2607:f8b0:400c:c01::22d]) by mx.google.com with ESMTPS id lb19si5047784vcb.71.2013.06.10.08.04.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 08:04:16 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22d is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22d; Received: by mail-ve0-f173.google.com with SMTP id jw11so4847393veb.4 for ; Mon, 10 Jun 2013 08:04:16 -0700 (PDT) X-Received: by 10.220.170.72 with SMTP id c8mr5905238vcz.14.1370876656086; Mon, 10 Jun 2013 08:04:16 -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.221.10.206 with SMTP id pb14csp71478vcb; Mon, 10 Jun 2013 08:04:15 -0700 (PDT) X-Received: by 10.14.201.7 with SMTP id a7mr11621468eeo.95.1370876652737; Mon, 10 Jun 2013 08:04:12 -0700 (PDT) Received: from eu1sys200aog119.obsmtp.com (eu1sys200aog119.obsmtp.com [207.126.144.147]) by mx.google.com with SMTP id n7si5573679eea.233.2013.06.10.08.04.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 10 Jun 2013 08:04:12 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.147; Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKUbXq6VlO3hyfD5de+SAteXGAjkJAD5zT@postini.com; Mon, 10 Jun 2013 15:04:12 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id A7CB241; Mon, 10 Jun 2013 15:03:05 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 1207C57; Mon, 10 Jun 2013 15:04:06 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id D7332A8065; Mon, 10 Jun 2013 17:03:59 +0200 (CEST) Received: from steludxu1397.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.279.5; Mon, 10 Jun 2013 17:04:05 +0200 From: Ulf Hansson To: , Chris Ball Cc: Ulf Hansson Subject: [PATCH 03/12] mmc: core: Push common suspend|resume code into each bus_ops Date: Mon, 10 Jun 2013 17:03:38 +0200 Message-ID: <1370876627-13439-4-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1370876627-13439-1-git-send-email-ulf.hansson@stericsson.com> References: <1370876627-13439-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm8d3O8Llh7937p5KBkzbfvRCTbiTzfQ5OB157NhiQ44oWYpRHl1VwSfNSvWxmVioNtdgqy X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22d 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 By moving code from the mmc_suspend|resume_host down into each .suspend|resume bus_ops callback, we get a more flexible solution. Some nice side effects are that we get a better understanding of each bus_ops suspend|resume sequence and the common code don't have to take care of specific corner cases, especially for the SDIO case. Signed-off-by: Ulf Hansson Tested-by: Jaehoon Chung --- drivers/mmc/core/core.c | 31 +++---------------------------- drivers/mmc/core/mmc.c | 4 ++++ drivers/mmc/core/sd.c | 4 ++++ drivers/mmc/core/sdio.c | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 7a8a42d..da3b907 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2621,9 +2621,6 @@ int mmc_suspend_host(struct mmc_host *host) { int err = 0; - cancel_delayed_work(&host->detect); - mmc_flush_scheduled_work(); - mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { if (host->bus_ops->suspend) @@ -2631,9 +2628,6 @@ int mmc_suspend_host(struct mmc_host *host) } mmc_bus_put(host); - if (!err && !mmc_card_keep_power(host)) - mmc_power_off(host); - return err; } EXPORT_SYMBOL(mmc_suspend_host); @@ -2644,39 +2638,20 @@ EXPORT_SYMBOL(mmc_suspend_host); */ int mmc_resume_host(struct mmc_host *host) { - int err = 0; + int err; mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { - if (!mmc_card_keep_power(host)) { - mmc_power_up(host); - mmc_select_voltage(host, host->ocr); - /* - * Tell runtime PM core we just powered up the card, - * since it still believes the card is powered off. - * Note that currently runtime PM is only enabled - * for SDIO cards that are MMC_CAP_POWER_OFF_CARD - */ - if (mmc_card_sdio(host->card) && - (host->caps & MMC_CAP_POWER_OFF_CARD)) { - pm_runtime_disable(&host->card->dev); - pm_runtime_set_active(&host->card->dev); - pm_runtime_enable(&host->card->dev); - } - } BUG_ON(!host->bus_ops->resume); err = host->bus_ops->resume(host); - if (err) { + if (err) pr_warning("%s: error %d during resume " "(card was removed?)\n", mmc_hostname(host), err); - err = 0; - } } - host->pm_flags &= ~MMC_PM_KEEP_POWER; mmc_bus_put(host); - return err; + return 0; } EXPORT_SYMBOL(mmc_resume_host); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 3a69b94..86ca103 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1494,6 +1494,8 @@ static int mmc_suspend(struct mmc_host *host) err = mmc_deselect_cards(host); host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); + if (!err) + mmc_power_off(host); out: mmc_release_host(host); return err; @@ -1513,6 +1515,8 @@ static int mmc_resume(struct mmc_host *host) BUG_ON(!host->card); mmc_claim_host(host); + mmc_power_up(host); + mmc_select_voltage(host, host->ocr); err = mmc_init_card(host, host->ocr, host->card); mmc_release_host(host); diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index aeaae7c..cacef27 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1075,6 +1075,8 @@ static int mmc_sd_suspend(struct mmc_host *host) if (!mmc_host_is_spi(host)) err = mmc_deselect_cards(host); host->card->state &= ~MMC_STATE_HIGHSPEED; + if (!err) + mmc_power_off(host); mmc_release_host(host); return err; @@ -1094,6 +1096,8 @@ static int mmc_sd_resume(struct mmc_host *host) BUG_ON(!host->card); mmc_claim_host(host); + mmc_power_up(host); + mmc_select_voltage(host, host->ocr); err = mmc_sd_init_card(host, host->ocr, host->card); mmc_release_host(host); diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index be8cca8..80d89cff 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -963,6 +963,9 @@ static int mmc_sdio_suspend(struct mmc_host *host) mmc_release_host(host); } + if (!err && !mmc_card_keep_power(host)) + mmc_power_off(host); + return err; } @@ -976,6 +979,23 @@ static int mmc_sdio_resume(struct mmc_host *host) /* Basic card reinitialization. */ mmc_claim_host(host); + /* Restore power if needed */ + if (!mmc_card_keep_power(host)) { + mmc_power_up(host); + mmc_select_voltage(host, host->ocr); + /* + * Tell runtime PM core we just powered up the card, + * since it still believes the card is powered off. + * Note that currently runtime PM is only enabled + * for SDIO cards that are MMC_CAP_POWER_OFF_CARD + */ + if (host->caps & MMC_CAP_POWER_OFF_CARD) { + pm_runtime_disable(&host->card->dev); + pm_runtime_set_active(&host->card->dev); + pm_runtime_enable(&host->card->dev); + } + } + /* No need to reinitialize powered-resumed nonremovable cards */ if (mmc_card_is_removable(host) || !mmc_card_keep_power(host)) { sdio_reset(host); @@ -1013,6 +1033,7 @@ static int mmc_sdio_resume(struct mmc_host *host) } } + host->pm_flags &= ~MMC_PM_KEEP_POWER; return err; }