@@ -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;
@@ -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);
@@ -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 */
@@ -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";