From patchwork Tue Mar 1 18:15:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Tardy X-Patchwork-Id: 600331 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p21IINM1024932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 1 Mar 2011 18:18:44 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.14.2/Debian-2build1) with ESMTP id p21IGVBE018054; Tue, 1 Mar 2011 10:16:31 -0800 Received: from mail-bw0-f47.google.com (mail-bw0-f47.google.com [209.85.214.47]) by smtp1.linux-foundation.org (8.14.2/8.14.2/Debian-2build1) with ESMTP id p21IFmLD017876 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 1 Mar 2011 10:15:54 -0800 Received: by mail-bw0-f47.google.com with SMTP id 10so4806785bwz.6 for ; Tue, 01 Mar 2011 10:15:54 -0800 (PST) Received: by 10.204.59.8 with SMTP id j8mr6426784bkh.26.1299003354284; Tue, 01 Mar 2011 10:15:54 -0800 (PST) Received: from localhost.localdomain ([82.240.198.215]) by mx.google.com with ESMTPS id d17sm1966327bkd.1.2011.03.01.10.15.51 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 01 Mar 2011 10:15:53 -0800 (PST) From: Pierre Tardy To: linux-kernel@vger.kernel.org, linux-pm@lists.linux-foundation.org, linux-mmc@vger.kernel.org Date: Tue, 1 Mar 2011 19:15:33 +0100 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-4.536 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SPF_PASS, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: Pierre Tardy Subject: [linux-pm] [RFC, PATCHv3 3/3] mmc: sdhci: handle wake-up from runtime_pm X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 01 Mar 2011 18:18:44 +0000 (UTC) diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 1b5e70b..fc3d2e1 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c @@ -1166,13 +1166,7 @@ static int sdhci_pci_runtime_suspend(struct device *dev) } pci_save_state(pdev); - if (pm_flags & MMC_PM_KEEP_POWER) { - if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) - pci_enable_wake(pdev, PCI_D3hot, 1); - } else { - pci_enable_wake(pdev, PCI_D3hot, 0); - pci_disable_device(pdev); - } + pci_enable_wake(pdev, PCI_D3hot, 1); pci_set_power_state(pdev, PCI_D3hot); return 0; 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. + */ + disable_irq_nosync(irq); + pm_runtime_get(host->mmc->parent); + 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/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h index a38d040..6a3c6af 100644 --- a/include/linux/mmc/sdhci.h +++ b/include/linux/mmc/sdhci.h @@ -146,6 +146,8 @@ struct sdhci_host { unsigned int ocr_avail_sd; unsigned int ocr_avail_mmc; + bool waking_up; + unsigned long private[0] ____cacheline_aligned; }; #endif /* __SDHCI_H */ 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";