All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Pierre Tardy <tardyp@gmail.com>
Cc: linux-pm@lists.linux-foundation.org, linux-mmc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC, PATCHv3 3/3] mmc: sdhci: handle wake-up from runtime_pm
Date: Tue, 1 Mar 2011 14:53:46 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1103011448430.2034-100000__12765.8834601336$1299009905$gmane$org@iolanthe.rowland.org> (raw)
In-Reply-To: <b01ca43311e25bf24c6e60e9f6d6d7b91ae3a130.1298820826.git.tardyp@gmail.com>

On Tue, 1 Mar 2011, Pierre Tardy wrote:

> When sdhci is runtime_suspended, it can still receive a wake-up
> because of card insertion.
> The wake-up will then be signaled by an interrupt which cannot be serviced
> immediatly, as the device is powered off, and register are not accessibles.
> 
> We cannot call pm_runtime_get_sync() in irq context as on some architecture (e.g. intel_mid),
> runtime_resume can lead to too much latency, due to e.g. PLL warm-up and such aggressive
> power gating.
> 
> We temporarly disable the interrupt, and trigger a runtime_resume of the device
> The interrupt will be re-enabled when resume is finished.
> 
> Signed-off-by: Pierre Tardy <tardyp@gmail.com>
> ---
>  drivers/mmc/host/sdhci-pci.c |    8 +-------
>  drivers/mmc/host/sdhci.c     |   30 +++++++++++++++++++++++++++++-
>  include/linux/mmc/sdhci.h    |    2 ++
>  scripts/checkpatch.pl        |    6 +++---
>  4 files changed, 35 insertions(+), 11 deletions(-)

> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 735c3f7..85a1956 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1599,6 +1599,21 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
>  	u32 intmask;
>  	int cardint = 0;
>  
> +	/* we might come from a sd insertion or sdio irq wake.. */
> +	if (pm_runtime_suspended()) {
> +		host->waking_up = 1;
> +		/* Note that we disable temporarly the interrupt until we do the
> +		 * resume. If we don't then we'll get constantly interrupted
> +		 * until we actually resume.
> +		 *
> +		 * as the irq is shared, this might not be very friendly to our
> +		 * irq sharers but the pm_runtime workqueue should really be
> +		 * called soon.

Instead of disabling the IRQ, would it be possible to tell the device 
to stop generating an interrupt request?

> +		 */
> +		disable_irq_nosync(irq);
> +		pm_runtime_get(host->mmc->parent);

Does this pm_runtime_get() have a corresponding pm_runtime_put()?  I 
didn't notice one anywhere.

> +		return IRQ_NONE;
> +	}
>  	spin_lock(&host->lock);
>  
>  	intmask = sdhci_readl(host, SDHCI_INT_STATUS);
> @@ -1747,7 +1762,12 @@ EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups);
>  
>  int sdhci_runtime_suspend(struct sdhci_host *host)
>  {
> -	/* nothing to do yet */
> +	u8 val;
> +	/* make sure we wake up on sdcard insert/remove enabled */
> +	val = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE;
> +	if (host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ)
> +		val |= SDHCI_WAKE_ON_INT;
> +	sdhci_writeb(host, val, SDHCI_WAKE_UP_CONTROL);
>  	return 0;
>  }
>  
> @@ -1768,6 +1788,14 @@ int sdhci_runtime_resume(struct sdhci_host *host)
>  	sdhci_set_ios(host->mmc, &host->mmc->ios);
>  	mmiowb();
>  
> +	if (host->waking_up) {
> +		host->waking_up = 0;
> +		/* Re-enable the irq now we are perfectly resumed.
> +		 * Any yet unhandled interrupt (i.e. the wake) will retrigger
> +		 * irq
> +		 */
> +		irq_enable(host->irq);
> +	}
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(sdhci_runtime_resume);

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index e3c7fc0..17aeda3 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1325,8 +1325,8 @@ sub process {
>  		$prefix = "$filename:$realline: " if ($emacs && $file);
>  		$prefix = "$filename:$linenr: " if ($emacs && !$file);
>  
> -		$here = "#$linenr: " if (!$file);
> -		$here = "#$realline: " if ($file);
> +		$here = "" if (!$file);
> +		$here = "" if ($file);
>  
>  		# extract the filename as it passes
>  		if ($line =~ /^diff --git.*?(\S+)$/) {
> @@ -1349,7 +1349,7 @@ sub process {
>  			next;
>  		}
>  
> -		$here .= "FILE: $realfile:$realline:" if ($realcnt != 0);
> +		$here .= "$realfile:$realline:" if ($realcnt != 0);
>  
>  		my $hereline = "$here\n$rawline\n";
>  		my $herecurr = "$here\n$rawline\n";
> 

Surely this doesn't belong in the patch.

Alan Stern

  reply	other threads:[~2011-03-01 19:53 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-01 18:15 [RFC,PATCHv3 0/3] sdhci runtime_pm implementation Pierre Tardy
2011-03-01 18:15 ` [RFC, PATCHv3 1/3] mmc: sdhci-pci: Enable runtime PM support Pierre Tardy
2011-03-01 18:15 ` [RFC,PATCHv3 " Pierre Tardy
2011-03-01 19:46   ` [RFC, PATCHv3 " Alan Stern
2011-03-01 19:46   ` [linux-pm] " Alan Stern
2011-03-01 19:46     ` Alan Stern
2011-03-01 18:15 ` [RFC,PATCHv3 2/3] mmc: sdhci: use ios->clock to know when sdhci is idle Pierre Tardy
2011-03-01 18:15 ` [RFC, PATCHv3 " Pierre Tardy
2011-03-01 18:15 ` [RFC,PATCHv3 3/3] mmc: sdhci: handle wake-up from runtime_pm Pierre Tardy
2011-03-01 19:53   ` Alan Stern [this message]
2011-03-01 19:53   ` [linux-pm] [RFC, PATCHv3 " Alan Stern
2011-03-01 19:53     ` Alan Stern
2011-03-01 20:01     ` Pierre Tardy
2011-03-01 20:01     ` [linux-pm] " Pierre Tardy
2011-03-01 20:27       ` Alan Stern
2011-03-01 20:27       ` [linux-pm] " Alan Stern
2011-03-01 20:27         ` Alan Stern
2011-03-01 20:48         ` Pierre Tardy
2011-03-01 20:48         ` [linux-pm] " Pierre Tardy
2011-03-01 18:15 ` Pierre Tardy
2011-03-01 19:33 ` [linux-pm] [RFC,PATCHv3 0/3] sdhci runtime_pm implementation Alan Stern
2011-03-01 19:33   ` Alan Stern
2011-03-01 19:36   ` Pierre Tardy
2011-03-01 19:57     ` Alan Stern
2011-03-01 19:57     ` [linux-pm] " Alan Stern
2011-03-01 19:57       ` Alan Stern
2011-03-01 20:06       ` Pierre Tardy
2011-03-01 20:06       ` [linux-pm] " Pierre Tardy
2011-03-01 20:30         ` Alan Stern
2011-03-01 20:30         ` [linux-pm] " Alan Stern
2011-03-01 20:30           ` Alan Stern
2011-03-01 21:07     ` Rafael J. Wysocki
2011-03-01 21:07     ` [linux-pm] " Rafael J. Wysocki
2011-03-01 23:40       ` Pierre Tardy
2011-03-01 23:40       ` [linux-pm] " Pierre Tardy
2011-03-01 23:49         ` Rafael J. Wysocki
2011-03-02 15:12           ` Alan Stern
2011-03-02 15:12           ` [linux-pm] " Alan Stern
2011-03-02 15:12             ` Alan Stern
2011-03-01 23:49         ` Rafael J. Wysocki
2011-03-01 19:36   ` Pierre Tardy
2011-03-01 19:33 ` Alan Stern

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='Pine.LNX.4.44L0.1103011448430.2034-100000__12765.8834601336$1299009905$gmane$org@iolanthe.rowland.org' \
    --to=stern@rowland.harvard.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=tardyp@gmail.com \
    /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.