From patchwork Thu Oct 13 14:03:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4656 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 B626923F58 for ; Thu, 13 Oct 2011 14:04:17 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9925BA18097 for ; Thu, 13 Oct 2011 14:04:17 +0000 (UTC) Received: by bkbzs2 with SMTP id zs2so547817bkb.11 for ; Thu, 13 Oct 2011 07:04:17 -0700 (PDT) Received: by 10.223.85.134 with SMTP id o6mr6374311fal.8.1318514657196; Thu, 13 Oct 2011 07:04:17 -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.152.24.41 with SMTP id r9cs262013laf; Thu, 13 Oct 2011 07:04:16 -0700 (PDT) Received: by 10.213.14.19 with SMTP id e19mr1396127eba.1.1318514655132; Thu, 13 Oct 2011 07:04:15 -0700 (PDT) Received: from eu1sys200aog106.obsmtp.com (eu1sys200aog106.obsmtp.com. [207.126.144.121]) by mx.google.com with SMTP id r56si1673133eef.158.2011.10.13.07.04.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Oct 2011 07:04:15 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.121 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.121; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.121 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 eu1sys200aob106.postini.com ([207.126.147.11]) with SMTP; Thu, 13 Oct 2011 14:04:14 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 00F0C13C; Thu, 13 Oct 2011 13:55:36 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 5475CFCC; Thu, 13 Oct 2011 14:04:05 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id BDAE1A8088; Thu, 13 Oct 2011 16:03:58 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 13 Oct 2011 16:04:03 +0200 From: Ulf Hansson To: , Chris Ball Cc: Per Forlin , Ulf Hansson , Lee Jones Subject: [PATCH] mmc: core: Prevent too long response times for suspend Date: Thu, 13 Oct 2011 16:03:58 +0200 Message-ID: <1318514638-32452-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.5.4 MIME-Version: 1.0 While trying to suspend the mmc host there could still be ongoing requests that we need to wait for. At the same time a device driver must respond to a suspend request rather quickly. Instead of potentially wait "forever" by claiming the host we now "try" to claim the host instead. If it fails, -EBUSY is returned. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 42 +++++++++++++++++++++++++++--------------- 1 files changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 61d7730..b900932 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2121,21 +2121,33 @@ int mmc_suspend_host(struct mmc_host *host) mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { - if (host->bus_ops->suspend) - err = host->bus_ops->suspend(host); - if (err == -ENOSYS || !host->bus_ops->resume) { - /* - * We simply "remove" the card in this case. - * It will be redetected on resume. - */ - if (host->bus_ops->remove) - host->bus_ops->remove(host); - mmc_claim_host(host); - mmc_detach_bus(host); - mmc_power_off(host); - mmc_release_host(host); - host->pm_flags = 0; - err = 0; + + /* + * A long response time is not acceptable for device drivers + * when doing suspend. Prevent mmc_claim_host in the suspend + * sequence, to potentially wait "forever" by trying to + * pre-claim the host. + */ + if (mmc_try_claim_host(host)) { + if (host->bus_ops->suspend) + err = host->bus_ops->suspend(host); + if (err == -ENOSYS || !host->bus_ops->resume) { + /* + * We simply "remove" the card in this case. + * It will be redetected on resume. + */ + if (host->bus_ops->remove) + host->bus_ops->remove(host); + mmc_claim_host(host); + mmc_detach_bus(host); + mmc_power_off(host); + mmc_release_host(host); + host->pm_flags = 0; + err = 0; + } + mmc_do_release_host(host); + } else { + err = -EBUSY; } } mmc_bus_put(host);