From patchwork Fri Mar 22 09:30:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 15528 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 E94A123E75 for ; Fri, 22 Mar 2013 09:30:39 +0000 (UTC) Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48]) by fiordland.canonical.com (Postfix) with ESMTP id 82E1EA1815F for ; Fri, 22 Mar 2013 09:30:39 +0000 (UTC) Received: by mail-vb0-f48.google.com with SMTP id fc21so2463485vbb.7 for ; Fri, 22 Mar 2013 02:30:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :mime-version:content-type:x-gm-message-state; bh=Gfj8uRqySEF/dkYibdYOMi9pfFZB6r07WNTFqtMGQKI=; b=HNLJ/86x6LxopGpAoUBC2wYkFCWvjeJW7rFIEc6T/Hy6Ty6k0GG7DpaTQfskhBGAZ/ VTeJUB20upaDFtW9X0IqouRRNIpiGudGWzAJAO0a5kiwcQCgpXKrEAML5HShSTngpjlu Mj480Yfkp7+1mm6I+0zRNSQJ2pFzg/Vde6CPnxfxWgH9ZnCj2nFQzTEDnasCpL2xHfGz ZpV6aJGwRnvoCkPQ/D0K4xRTOBEVo/xfuH/lH6k563LduI6Twass280ESK3xQankupC1 POiCkoz7bWbgqzlouznkKMgmKxcrDfpuiwd7Ff6XozLnE9en0L0GxS00VJ5GPXzRS5NI Hn4g== X-Received: by 10.58.29.101 with SMTP id j5mr1257982veh.26.1363944638955; Fri, 22 Mar 2013 02:30:38 -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.58.233.198 with SMTP id ty6csp97203vec; Fri, 22 Mar 2013 02:30:38 -0700 (PDT) X-Received: by 10.14.111.72 with SMTP id v48mr3316706eeg.11.1363944637377; Fri, 22 Mar 2013 02:30:37 -0700 (PDT) Received: from eu1sys200aog119.obsmtp.com (eu1sys200aog119.obsmtp.com [207.126.144.147]) by mx.google.com with SMTP id f9si2218186eep.255.2013.03.22.02.30.33 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Mar 2013 02:30:37 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.147; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.147 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKUUwktopl6R2EUbyWJ52rWqrSoKmuS6Zm@postini.com; Fri, 22 Mar 2013 09:30:36 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 0CB31DF; Fri, 22 Mar 2013 09:22:15 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 70700852; Fri, 22 Mar 2013 09:30:24 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id EB2D8A8065; Fri, 22 Mar 2013 10:30:19 +0100 (CET) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.279.5; Fri, 22 Mar 2013 10:30:23 +0100 From: Ulf Hansson To: , Chris Ball Cc: Ulf Hansson Subject: [PATCH] mmc: core: Decrease the card detect frequency in polling mode Date: Fri, 22 Mar 2013 10:30:19 +0100 Message-ID: <1363944619-19829-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmowgjlP4f3oPl1qIuYEzzi2QIeSuKZ+t/bK1FgrxjuRqICxvSjy5a+klyBYrAaa6dC3drp From: Ulf Hansson Previously the MMC_CAP2_DETECT_ON_ERR was invented for detecting slow card removal. In was never a realy good solution and a proper fix shall use gpio debouncing instead. We remove this cap in this patch. Although when running in polling card detect mode, the code can be re-used to detect card removals. Thus we are able to decrease the frequency of issued detect works from the mmc_rescan function. When no card is inserted the polling timeout is 1 HZ. When card is inserted and detected the polling timeout is increased to 30 s. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 10 ++++++---- include/linux/mmc/host.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 08a3cf2..3a83cdc 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2312,14 +2312,13 @@ int mmc_detect_card_removed(struct mmc_host *host) * The card will be considered unchanged unless we have been asked to * detect a change or host requires polling to provide card detection. */ - if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL) && - !(host->caps2 & MMC_CAP2_DETECT_ON_ERR)) + if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL)) return ret; host->detect_change = 0; if (!ret) { ret = _mmc_detect_card_removed(host); - if (ret && (host->caps2 & MMC_CAP2_DETECT_ON_ERR)) { + if (ret && (host->caps & MMC_CAP_NEEDS_POLL)) { /* * Schedule a detect work as soon as possible to let a * rescan handle the card removal. @@ -2338,6 +2337,7 @@ void mmc_rescan(struct work_struct *work) struct mmc_host *host = container_of(work, struct mmc_host, detect.work); int i; + unsigned int polltimeout_s = 1; if (host->rescan_disable) return; @@ -2368,6 +2368,8 @@ void mmc_rescan(struct work_struct *work) /* if there still is a card present, stop here */ if (host->bus_ops != NULL) { + /* set the poll timeout to 30 s when card is inserted */ + polltimeout_s = 30; mmc_bus_put(host); goto out; } @@ -2396,7 +2398,7 @@ void mmc_rescan(struct work_struct *work) out: if (host->caps & MMC_CAP_NEEDS_POLL) - mmc_schedule_delayed_work(&host->detect, HZ); + mmc_schedule_delayed_work(&host->detect, polltimeout_s * HZ); } void mmc_start_host(struct mmc_host *host) diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index d6f20cc..a018e2d 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -272,7 +272,6 @@ struct mmc_host { #define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \ MMC_CAP2_HS200_1_2V_SDR) #define MMC_CAP2_BROKEN_VOLTAGE (1 << 7) /* Use the broken voltage */ -#define MMC_CAP2_DETECT_ON_ERR (1 << 8) /* On I/O err check card removal */ #define MMC_CAP2_HC_ERASE_SZ (1 << 9) /* High-capacity erase size */ #define MMC_CAP2_CD_ACTIVE_HIGH (1 << 10) /* Card-detect signal active high */ #define MMC_CAP2_RO_ACTIVE_HIGH (1 << 11) /* Write-protect signal active high */