From patchwork Fri Jun 10 10:42:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1809 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.45.109) by localhost6.localdomain6 with IMAP4-SSL; 10 Jun 2011 20:11:56 -0000 Delivered-To: patches@linaro.org Received: by 10.52.181.10 with SMTP id ds10cs303905vdc; Fri, 10 Jun 2011 03:34:16 -0700 (PDT) Received: by 10.231.24.197 with SMTP id w5mr2275255ibb.192.1307702056144; Fri, 10 Jun 2011 03:34:16 -0700 (PDT) Received: from mail-pv0-f178.google.com (mail-pv0-f178.google.com [74.125.83.178]) by mx.google.com with ESMTPS id v8si6909712ibv.147.2011.06.10.03.34.15 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Jun 2011 03:34:16 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) client-ip=74.125.83.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) smtp.mail=shawn.guo@linaro.org Received: by pvg7 with SMTP id 7so1327091pvg.37 for ; Fri, 10 Jun 2011 03:34:15 -0700 (PDT) Received: by 10.68.29.69 with SMTP id i5mr873062pbh.62.1307702055085; Fri, 10 Jun 2011 03:34:15 -0700 (PDT) Received: from localhost.localdomain ([180.106.33.11]) by mx.google.com with ESMTPS id b8sm2219406pbj.78.2011.06.10.03.33.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Jun 2011 03:34:14 -0700 (PDT) From: Shawn Guo To: linux-mmc@vger.kernel.org Cc: Chris Ball , Wolfram Sang , Eric Benard , Arnaud Patard , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, patches@linaro.org, Shawn Guo Subject: [PATCH 1/4] mmc: sdhci: fix interrupt storm from card detection Date: Fri, 10 Jun 2011 18:42:49 +0800 Message-Id: <1307702572-22066-2-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1307702572-22066-1-git-send-email-shawn.guo@linaro.org> References: <1307702572-22066-1-git-send-email-shawn.guo@linaro.org> The issue was initially found by Eric Benard as below. http://permalink.gmane.org/gmane.linux.ports.arm.kernel/108031 Not sure about other SDHCI based controller, but on Freescale eSDHC, the SDHCI_INT_CARD_INSERT bits will be immediately set again when it gets cleared, if a card is inserted. The driver need to mask the irq to prevent interrupt storm which will freeze the system. And the SDHCI_INT_CARD_REMOVE gets the same situation. The patch fixes the problem based on the initial idea from Eric Benard. Signed-off-by: Shawn Guo Cc: Eric Benard --- drivers/mmc/host/sdhci.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 91d9892..71a2505 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2154,13 +2154,20 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) 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; + + sdhci_mask_irqs(host, present ? SDHCI_INT_CARD_INSERT : + SDHCI_INT_CARD_REMOVE); + sdhci_unmask_irqs(host, present ? SDHCI_INT_CARD_REMOVE : + SDHCI_INT_CARD_INSERT); + sdhci_writel(host, intmask & (SDHCI_INT_CARD_INSERT | - SDHCI_INT_CARD_REMOVE), SDHCI_INT_STATUS); + SDHCI_INT_CARD_REMOVE), SDHCI_INT_STATUS); + intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); tasklet_schedule(&host->card_tasklet); } - intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); - if (intmask & SDHCI_INT_CMD_MASK) { sdhci_writel(host, intmask & SDHCI_INT_CMD_MASK, SDHCI_INT_STATUS);