From patchwork Thu Jan 19 16:39:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 6299 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 5EE3F23F02 for ; Thu, 19 Jan 2012 16:40:23 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 4E1ACA18476 for ; Thu, 19 Jan 2012 16:40:23 +0000 (UTC) Received: by mail-bk0-f52.google.com with SMTP id zt4so155367bkb.11 for ; Thu, 19 Jan 2012 08:40:23 -0800 (PST) Received: by 10.205.26.67 with SMTP id rl3mr10530761bkb.45.1326991223125; Thu, 19 Jan 2012 08:40:23 -0800 (PST) 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.205.82.144 with SMTP id ac16cs16894bkc; Thu, 19 Jan 2012 08:40:22 -0800 (PST) Received: by 10.213.34.135 with SMTP id l7mr7236690ebd.42.1326991221479; Thu, 19 Jan 2012 08:40:21 -0800 (PST) Received: from eu1sys200aog119.obsmtp.com (eu1sys200aog119.obsmtp.com. [207.126.144.147]) by mx.google.com with SMTP id 41si15817757eeu.85.2012.01.19.08.40.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jan 2012 08:40:21 -0800 (PST) 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-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKTxhHb7dODS3Xr0pjhsSp/T1BzxptsSp+@postini.com; Thu, 19 Jan 2012 16:40:21 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 909BB10E; Thu, 19 Jan 2012 16:39:58 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E0DCD29F5; Thu, 19 Jan 2012 16:39:57 +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 relay1.stm.gmessaging.net (Postfix) with ESMTPS id 792AE24C075; Thu, 19 Jan 2012 17:39:49 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 19 Jan 2012 17:39:57 +0100 From: Ulf Hansson To: , Chris Ball Cc: Adrian Hunter , Per Forlin , Ulf Hansson , Johan Rudholm , Lee Jones Subject: [PATCH 1/2] mmc: core: Prevent I/O as soon as possible at card removal Date: Thu, 19 Jan 2012 17:39:50 +0100 Message-ID: <1326991191-12472-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1326991191-12472-1-git-send-email-ulf.hansson@stericsson.com> References: <1326991191-12472-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 Once the card has been detected to be removed by the mmc_detect_card_removed function, schedule a new detect work immediately and without a delay to let a rescan remove the card device as soon a possible. This will sooner prevent further I/O requests. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index bec0bf2..265dfd8 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2077,6 +2077,7 @@ int _mmc_detect_card_removed(struct mmc_host *host) int mmc_detect_card_removed(struct mmc_host *host) { struct mmc_card *card = host->card; + int ret; WARN_ON(!host->claimed); /* @@ -2086,9 +2087,20 @@ int mmc_detect_card_removed(struct mmc_host *host) if (card && !host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL)) return mmc_card_removed(card); - host->detect_change = 0; + ret = mmc_card_removed(card); + if (!ret) { + ret = _mmc_detect_card_removed(host); + if (ret) { + /* + * Schedule a detect work as soon as possible to let a + * rescan handle the card removal. + */ + cancel_delayed_work(&host->detect); + mmc_detect_change(host, 0); + } + } - return _mmc_detect_card_removed(host); + return ret; } EXPORT_SYMBOL(mmc_detect_card_removed);