From patchwork Wed Jun 15 11:15:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1919 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CD2F124B31 for ; Wed, 15 Jun 2011 11:10:18 +0000 (UTC) Received: from mail-vw0-f52.google.com (mail-vw0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 86A79A1892A for ; Wed, 15 Jun 2011 11:10:18 +0000 (UTC) Received: by vws16 with SMTP id 16so252074vws.11 for ; Wed, 15 Jun 2011 04:10:18 -0700 (PDT) Received: by 10.52.75.4 with SMTP id y4mr542985vdv.167.1308136218041; Wed, 15 Jun 2011 04:10:18 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs118266vdc; Wed, 15 Jun 2011 04:10:17 -0700 (PDT) Received: by 10.224.135.133 with SMTP id n5mr261637qat.392.1308136217476; Wed, 15 Jun 2011 04:10:17 -0700 (PDT) Received: from TX2EHSOBE009.bigfish.com (tx2ehsobe004.messaging.microsoft.com [65.55.88.14]) by mx.google.com with ESMTPS id g32si438111qca.103.2011.06.15.04.10.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 15 Jun 2011 04:10:16 -0700 (PDT) Received-SPF: neutral (google.com: 65.55.88.14 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) client-ip=65.55.88.14; Authentication-Results: mx.google.com; spf=neutral (google.com: 65.55.88.14 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) smtp.mail=shawn.guo@linaro.org Received: from mail178-tx2-R.bigfish.com (10.9.14.241) by TX2EHSOBE009.bigfish.com (10.9.40.29) with Microsoft SMTP Server id 14.1.225.22; Wed, 15 Jun 2011 11:10:15 +0000 Received: from mail178-tx2 (localhost.localdomain [127.0.0.1]) by mail178-tx2-R.bigfish.com (Postfix) with ESMTP id 4CCC0D18397; Wed, 15 Jun 2011 11:10:15 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bh8275dhz2dh87h2a8h668h839h63h) X-Spam-TCS-SCL: 2:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-DOMAIN-IP-MATCH: fail Received: from mail178-tx2 (localhost.localdomain [127.0.0.1]) by mail178-tx2 (MessageSwitch) id 1308136200219613_13906; Wed, 15 Jun 2011 11:10:00 +0000 (UTC) Received: from TX2EHSMHS023.bigfish.com (unknown [10.9.14.245]) by mail178-tx2.bigfish.com (Postfix) with ESMTP id 177321000052; Wed, 15 Jun 2011 11:10:00 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS023.bigfish.com (10.9.99.123) with Microsoft SMTP Server (TLS) id 14.1.225.22; Wed, 15 Jun 2011 11:09:55 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.289.8; Wed, 15 Jun 2011 06:09:54 -0500 Received: from S2100-06.ap.freescale.net (S2100-06.ap.freescale.net [10.192.242.125]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id p5FB9l3F013936; Wed, 15 Jun 2011 06:09:51 -0500 (CDT) From: Shawn Guo To: CC: Chris Ball , Wolfram Sang , Arnaud Patard , Eric Benard , Pavel Machek , , , , Shawn Guo Subject: [PATCH v2 1/4] mmc: sdhci: fix interrupt storm from card detection Date: Wed, 15 Jun 2011 19:15:19 +0800 Message-ID: <1308136522-3403-2-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1308136522-3403-1-git-send-email-shawn.guo@linaro.org> References: <1308136522-3403-1-git-send-email-shawn.guo@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com 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 | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 91d9892..0dd10e4 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2154,13 +2154,30 @@ 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; + + /* + * There is a observation on i.mx esdhc. INSERT bit will be + * immediately set again when it gets cleared, if a card is + * inserted. We have to mask the irq to prevent interrupt + * storm which will freeze the system. And the REMOVE gets + * the same situation. + * + * More testing are needed here to ensure it works for other + * platforms though. + */ + 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);