All of lore.kernel.org
 help / color / mirror / Atom feed
From: Doug Anderson <dianders@chromium.org>
To: Jaehoon Chung <jh80.chung@samsung.com>,
	Seungwon Jeon <tgih.jun@samsung.com>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
	Sonny Rao <sonnyrao@chromium.org>,
	Andrew Bresticker <abrestic@chromium.org>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org,
	Doug Anderson <dianders@chromium.org>,
	chris@printf.net, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2] mmc: dw_mmc: Turn the card clock off at suspend time
Date: Wed, 19 Nov 2014 11:37:21 -0800	[thread overview]
Message-ID: <1416425841-12681-1-git-send-email-dianders@chromium.org> (raw)

Since the dw_mmc driver was first added to Linux it's had a TODO in it
that we should turn off the card clock during suspend.  I have no idea
for sure why it wasn't done originally, but if I had to guess I'd
guess it was related to the lack of a common clock framework.  Let's
do it now.

There is no reason for the card clock to be left on during suspend and
most systems will eventually turn it off anyway (when whole clock
trees are disabled).  However, it's good to be explicit that it's
disabled at the time that the MMC subsystem is disabled.

This actually fixes a bug on Rockchip rk3288 where an SDIO card wakes
the system back up during suspend.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
Changes in v2:
- Handle fact that ciu_clk is optional (abrestic)
- Check for errors enabling ciu_clk (abrestic)

 drivers/mmc/host/dw_mmc.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 5a37c33..49f4013 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2825,11 +2825,11 @@ EXPORT_SYMBOL(dw_mci_remove);
 
 
 #ifdef CONFIG_PM_SLEEP
-/*
- * TODO: we should probably disable the clock to the card in the suspend path.
- */
 int dw_mci_suspend(struct dw_mci *host)
 {
+	if (!IS_ERR(host->ciu_clk))
+		clk_disable(host->ciu_clk);
+
 	return 0;
 }
 EXPORT_SYMBOL(dw_mci_suspend);
@@ -2838,9 +2838,15 @@ int dw_mci_resume(struct dw_mci *host)
 {
 	int i, ret;
 
+	if (!IS_ERR(host->ciu_clk)) {
+		ret = clk_enable(host->ciu_clk);
+		if (ret)
+			return ret;
+	}
+
 	if (!dw_mci_ctrl_reset(host, SDMMC_CTRL_ALL_RESET_FLAGS)) {
 		ret = -ENODEV;
-		return ret;
+		goto exit_ciu_enabled;
 	}
 
 	if (host->use_dma && host->dma_ops->init)
@@ -2871,7 +2877,14 @@ int dw_mci_resume(struct dw_mci *host)
 			dw_mci_setup_bus(slot, true);
 		}
 	}
+
 	return 0;
+
+exit_ciu_enabled:
+	if (!IS_ERR(host->ciu_clk))
+		clk_disable(host->ciu_clk);
+
+	return ret;
 }
 EXPORT_SYMBOL(dw_mci_resume);
 #endif /* CONFIG_PM_SLEEP */
-- 
2.1.0.rc2.206.gedb03e5


WARNING: multiple messages have this Message-ID (diff)
From: dianders@chromium.org (Doug Anderson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] mmc: dw_mmc: Turn the card clock off at suspend time
Date: Wed, 19 Nov 2014 11:37:21 -0800	[thread overview]
Message-ID: <1416425841-12681-1-git-send-email-dianders@chromium.org> (raw)

Since the dw_mmc driver was first added to Linux it's had a TODO in it
that we should turn off the card clock during suspend.  I have no idea
for sure why it wasn't done originally, but if I had to guess I'd
guess it was related to the lack of a common clock framework.  Let's
do it now.

There is no reason for the card clock to be left on during suspend and
most systems will eventually turn it off anyway (when whole clock
trees are disabled).  However, it's good to be explicit that it's
disabled at the time that the MMC subsystem is disabled.

This actually fixes a bug on Rockchip rk3288 where an SDIO card wakes
the system back up during suspend.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
Changes in v2:
- Handle fact that ciu_clk is optional (abrestic)
- Check for errors enabling ciu_clk (abrestic)

 drivers/mmc/host/dw_mmc.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 5a37c33..49f4013 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2825,11 +2825,11 @@ EXPORT_SYMBOL(dw_mci_remove);
 
 
 #ifdef CONFIG_PM_SLEEP
-/*
- * TODO: we should probably disable the clock to the card in the suspend path.
- */
 int dw_mci_suspend(struct dw_mci *host)
 {
+	if (!IS_ERR(host->ciu_clk))
+		clk_disable(host->ciu_clk);
+
 	return 0;
 }
 EXPORT_SYMBOL(dw_mci_suspend);
@@ -2838,9 +2838,15 @@ int dw_mci_resume(struct dw_mci *host)
 {
 	int i, ret;
 
+	if (!IS_ERR(host->ciu_clk)) {
+		ret = clk_enable(host->ciu_clk);
+		if (ret)
+			return ret;
+	}
+
 	if (!dw_mci_ctrl_reset(host, SDMMC_CTRL_ALL_RESET_FLAGS)) {
 		ret = -ENODEV;
-		return ret;
+		goto exit_ciu_enabled;
 	}
 
 	if (host->use_dma && host->dma_ops->init)
@@ -2871,7 +2877,14 @@ int dw_mci_resume(struct dw_mci *host)
 			dw_mci_setup_bus(slot, true);
 		}
 	}
+
 	return 0;
+
+exit_ciu_enabled:
+	if (!IS_ERR(host->ciu_clk))
+		clk_disable(host->ciu_clk);
+
+	return ret;
 }
 EXPORT_SYMBOL(dw_mci_resume);
 #endif /* CONFIG_PM_SLEEP */
-- 
2.1.0.rc2.206.gedb03e5

             reply	other threads:[~2014-11-19 19:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-19 19:37 Doug Anderson [this message]
2014-11-19 19:37 ` [PATCH v2] mmc: dw_mmc: Turn the card clock off at suspend time Doug Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416425841-12681-1-git-send-email-dianders@chromium.org \
    --to=dianders@chromium.org \
    --cc=abrestic@chromium.org \
    --cc=alim.akhtar@samsung.com \
    --cc=chris@printf.net \
    --cc=heiko@sntech.de \
    --cc=jh80.chung@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=sonnyrao@chromium.org \
    --cc=tgih.jun@samsung.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.