From patchwork Tue Jul 9 15:44:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremie Samuel X-Patchwork-Id: 2825337 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D85309F7D6 for ; Tue, 9 Jul 2013 15:44:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91123201C2 for ; Tue, 9 Jul 2013 15:44:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 391362011D for ; Tue, 9 Jul 2013 15:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751722Ab3GIPoq (ORCPT ); Tue, 9 Jul 2013 11:44:46 -0400 Received: from co202.xi-lite.net ([149.6.83.202]:45921 "EHLO co202.xi-lite.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653Ab3GIPop (ORCPT ); Tue, 9 Jul 2013 11:44:45 -0400 Received: from ONYX.xi-lite.lan (unknown [193.34.35.244]) by co202.xi-lite.net (Postfix) with ESMTPS id D65F7168A7D; Tue, 9 Jul 2013 18:05:02 +0200 (CEST) Received: from jerk.parrot.biz (46.218.109.88) by mail.xi-lite.com (193.34.32.105) with Microsoft SMTP Server (TLS) id 8.1.336.0; Tue, 9 Jul 2013 16:45:39 +0100 From: Jeremie Samuel To: Chris Ball CC: , , , Jeremie Samuel , Anton Vorontsov Subject: [PATCH 4/8] sdhci: Use threaded IRQ handler Date: Tue, 9 Jul 2013 17:44:08 +0200 Message-ID: <1373384652-21958-5-git-send-email-jeremie.samuel.ext@parrot.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373384652-21958-1-git-send-email-jeremie.samuel.ext@parrot.com> References: <1373384652-21958-1-git-send-email-jeremie.samuel.ext@parrot.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Jeremie Samuel --- drivers/mmc/host/sdhci.c | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index ab635d5..21ef1e0 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2405,9 +2405,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; @@ -2423,15 +2422,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; @@ -2491,12 +2482,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) { @@ -2510,7 +2499,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; } /*****************************************************************************\ @@ -2597,8 +2606,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 { @@ -3213,8 +3223,8 @@ int sdhci_add_host(struct sdhci_host *host) sdhci_tuning_timeout_work); } - 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);