]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: sdhci: Use threaded IRQ handler
authorJeremie Samuel <jeremie.samuel.ext@parrot.com>
Mon, 21 Oct 2013 15:25:53 +0000 (17:25 +0200)
committerChris Ball <chris@printf.net>
Mon, 21 Oct 2013 19:58:35 +0000 (15:58 -0400)
We only need atomic context to disable SDHCI interrupts, after that
we can run in a kernel thread.

Note that irq handler still grabs an irqsave spinlock, we'll deal
with it in a subsequent patch.

Patch based on: http://thread.gmane.org/gmane.linux.kernel.mmc/2579.

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
Signed-off-by: Jeremie Samuel <jeremie.samuel.ext@parrot.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/sdhci.c

index 53befafe8ff8efe0404559067af0e36a43c80500..e8232157008231abe9a614d859f9ccc18f2cbf3a 100644 (file)
@@ -2415,9 +2415,8 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
        }
 }
 
-static irqreturn_t sdhci_irq(int irq, void *dev_id)
+static irqreturn_t sdhci_irq_thread(int irq, void *dev_id)
 {
-       irqreturn_t result;
        struct sdhci_host *host = dev_id;
        u32 intmask, unexpected = 0;
        int cardint = 0, max_loops = 16;
@@ -2433,15 +2432,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
 
        intmask = sdhci_readl(host, SDHCI_INT_STATUS);
 
-       if (!intmask || intmask == 0xffffffff) {
-               result = IRQ_NONE;
-               goto out;
-       }
-
 again:
-       DBG("*** %s got interrupt: 0x%08x\n",
-               mmc_hostname(host->mmc), intmask);
-
        if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
                u32 present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
                              SDHCI_CARD_PRESENT;
@@ -2501,12 +2492,10 @@ again:
                sdhci_writel(host, intmask, SDHCI_INT_STATUS);
        }
 
-       result = IRQ_HANDLED;
-
        intmask = sdhci_readl(host, SDHCI_INT_STATUS);
        if (intmask && --max_loops)
                goto again;
-out:
+
        spin_unlock(&host->lock);
 
        if (unexpected) {
@@ -2520,7 +2509,27 @@ out:
        if (cardint)
                mmc_signal_sdio_irq(host->mmc);
 
-       return result;
+       intmask = sdhci_readl(host, SDHCI_INT_ENABLE);
+       sdhci_writel(host, intmask, SDHCI_SIGNAL_ENABLE);
+
+       return IRQ_HANDLED;
+}
+
+static irqreturn_t sdhci_irq(int irq, void *dev_id)
+{
+       struct sdhci_host *host = dev_id;
+       u32 intmask = sdhci_readl(host, SDHCI_INT_STATUS);
+
+       if (!intmask || intmask == 0xffffffff)
+               return IRQ_NONE;
+
+       /* Disable interrupts */
+       sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
+
+       DBG("*** %s got interrupt: 0x%08x\n",
+               mmc_hostname(host->mmc), intmask);
+
+       return IRQ_WAKE_THREAD;
 }
 
 /*****************************************************************************\
@@ -2607,8 +2616,9 @@ int sdhci_resume_host(struct sdhci_host *host)
        }
 
        if (!device_may_wakeup(mmc_dev(host->mmc))) {
-               ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
-                                 mmc_hostname(host->mmc), host);
+               ret = request_threaded_irq(host->irq, sdhci_irq,
+                       sdhci_irq_thread, IRQF_SHARED,
+                       mmc_hostname(host->mmc), host);
                if (ret)
                        return ret;
        } else {
@@ -3228,8 +3238,8 @@ int sdhci_add_host(struct sdhci_host *host)
 
        sdhci_init(host, 0);
 
-       ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
-               mmc_hostname(mmc), host);
+       ret = request_threaded_irq(host->irq, sdhci_irq, sdhci_irq_thread,
+                         IRQF_SHARED, mmc_hostname(host->mmc), host);
        if (ret) {
                pr_err("%s: Failed to request IRQ %d: %d\n",
                       mmc_hostname(mmc), host->irq, ret);