From patchwork Wed Aug 21 10:44:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haijun.Zhang@freescale.com X-Patchwork-Id: 2847678 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 C584F9F271 for ; Wed, 21 Aug 2013 10:45:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB2FD20137 for ; Wed, 21 Aug 2013 10:45:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 863BB20123 for ; Wed, 21 Aug 2013 10:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751273Ab3HUKpn (ORCPT ); Wed, 21 Aug 2013 06:45:43 -0400 Received: from co9ehsobe004.messaging.microsoft.com ([207.46.163.27]:17113 "EHLO co9outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751238Ab3HUKpm (ORCPT ); Wed, 21 Aug 2013 06:45:42 -0400 Received: from mail9-co9-R.bigfish.com (10.236.132.230) by CO9EHSOBE003.bigfish.com (10.236.130.66) with Microsoft SMTP Server id 14.1.225.22; Wed, 21 Aug 2013 10:45:41 +0000 Received: from mail9-co9 (localhost [127.0.0.1]) by mail9-co9-R.bigfish.com (Postfix) with ESMTP id C351B7400E3; Wed, 21 Aug 2013 10:45:41 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h8275bh1de097hz2dh2a8h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h1155h) Received: from mail9-co9 (localhost.localdomain [127.0.0.1]) by mail9-co9 (MessageSwitch) id 137708194141562_12983; Wed, 21 Aug 2013 10:45:41 +0000 (UTC) Received: from CO9EHSMHS031.bigfish.com (unknown [10.236.132.232]) by mail9-co9.bigfish.com (Postfix) with ESMTP id F01D48C004A; Wed, 21 Aug 2013 10:45:40 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS031.bigfish.com (10.236.130.41) with Microsoft SMTP Server (TLS) id 14.16.227.3; Wed, 21 Aug 2013 10:45:39 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.146.2; Wed, 21 Aug 2013 10:45:38 +0000 Received: from rock.am.freescale.net (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r7LAjWp3002135; Wed, 21 Aug 2013 03:45:34 -0700 From: Haijun Zhang To: , CC: , , , , Haijun Zhang , Haijun Zhang Subject: [PATCH] mmc:core: Avoid useless detecting task when card is busy Date: Wed, 21 Aug 2013 18:44:18 +0800 Message-ID: <1377081858-17430-1-git-send-email-Haijun.Zhang@freescale.com> X-Mailer: git-send-email 1.8.0 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 When card is in cpu polling mode to detect card present. Card detecting task will be scheduled about once every second. When card is busy in large file transfer, detecting task will be hang and call trace will be prompt. In this case, when card is busy assume that card is present and just return in detecting task. Only polling card in case card is free to reduce conflict with data transfer. <7>mmc0: req done (CMD13): 0: 00000e00 00000000 00000000 00000000 INFO: task kworker/u:1:12 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u:1 D 00000000 0 12 2 0x00000000 Call Trace: [ee06dd50] [44042028] 0x44042028 (unreliable) [ee06de10] [c0007a0c] __switch_to+0xa0/0xf0 [ee06de30] [c04dd50c] __schedule+0x1f8/0x4a4 [ee06dea0] [c04dd898] schedule+0x30/0xbc [ee06deb0] [c03816a4] __mmc_claim_host+0x98/0x19c [ee06df00] [c0385f88] mmc_sd_detect+0x38/0xc0 [ee06df10] [c0382b0c] mmc_rescan+0x294/0x2e0 [ee06df40] [c00661cc] process_one_work+0x140/0x3e0 [ee06df70] [c0066bf8] worker_thread+0x18c/0x36c [ee06dfb0] [c006bf10] kthread+0x7c/0x80 [ee06dff0] [c000de58] kernel_thread+0x4c/0x68 <7>sdhci [sdhci_irq()]: *** mmc0 got interrupt: 0x00000001 Signed-off-by: Haijun Zhang --- drivers/mmc/core/core.c | 5 +++++ drivers/mmc/core/mmc.c | 3 ++- drivers/mmc/core/sd.c | 3 ++- drivers/mmc/core/sdio.c | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 49a5bca..d51d9bd 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -924,15 +924,20 @@ EXPORT_SYMBOL(__mmc_claim_host); */ int mmc_try_claim_host(struct mmc_host *host) { + struct mmc_card *card; int claimed_host = 0; unsigned long flags; + card = host->card; + pm_runtime_get_sync(&card->dev); + spin_lock_irqsave(&host->lock, flags); if (!host->claimed || host->claimer == current) { host->claimed = 1; host->claimer = current; host->claim_cnt += 1; claimed_host = 1; + set_current_state(TASK_RUNNING); } spin_unlock_irqrestore(&host->lock, flags); if (host->ops->enable && claimed_host && host->claim_cnt == 1) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 6d02012..90e5555 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1447,7 +1447,8 @@ static void mmc_detect(struct mmc_host *host) BUG_ON(!host); BUG_ON(!host->card); - mmc_get_card(host->card); + if (!mmc_try_claim_host(host)) + return; /* * Just check if our card has been removed. diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 176d125..6aae8d1 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1042,7 +1042,8 @@ static void mmc_sd_detect(struct mmc_host *host) BUG_ON(!host); BUG_ON(!host->card); - mmc_get_card(host->card); + if (!mmc_try_claim_host(host)) + return; /* * Just check if our card has been removed. diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 80d89cff..e0cabf5 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -875,7 +875,8 @@ static void mmc_sdio_detect(struct mmc_host *host) } } - mmc_claim_host(host); + if (!mmc_try_claim_host(host)) + return; /* * Just check if our card has been removed.