From patchwork Thu Apr 19 09:55:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 7941 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 6804A23E42 for ; Thu, 19 Apr 2012 09:55:53 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0C7B5A18A2D for ; Thu, 19 Apr 2012 09:55:52 +0000 (UTC) Received: by iage36 with SMTP id e36so16018553iag.11 for ; Thu, 19 Apr 2012 02:55:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=QkJyKGQgps3+K0A5pvQCnX3W9hTmXG4rj286AfKhZT0=; b=hSnwIXkshxIkAZmQPAE68WGiuTwyvjOSyr1z1lbOtw//3tGyijl2U23xdHCF8m6Tq4 Hv+1z6IvXBqWAxkLQy8QlUARG3TcYcd18mTbJER/d7O03270n/szJNf7C4S9JRwuafyI icKq8bhpdipYR1oSQ45U0wI6k4YJksfm7hAvR7XHExHcXz+uPyXA90x68il4oOW44ve8 OdaBAp/J6B7V9LCTZYICtvTlJ6bNZPTpVkjsiU1RF6hT1YonIujaECvkVgEap0DH5Ksk kAyWThodPoC0eu9wwbvi2qbhT8XZ3dQHA2ysKT/JpvcM6SqUuVX4GZmVk6qssth0m3GK 7paw== Received: by 10.43.49.201 with SMTP id vb9mr887336icb.35.1334829352477; Thu, 19 Apr 2012 02:55:52 -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.231.137.198 with SMTP id x6csp277646ibt; Thu, 19 Apr 2012 02:55:51 -0700 (PDT) Received: by 10.14.29.13 with SMTP id h13mr193757eea.48.1334829351112; Thu, 19 Apr 2012 02:55:51 -0700 (PDT) Received: from eu1sys200aog107.obsmtp.com (eu1sys200aog107.obsmtp.com. [207.126.144.123]) by mx.google.com with SMTP id a45si438316eeg.54.2012.04.19.02.55.48 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Apr 2012 02:55:51 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.123 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.123; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.123 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 eu1sys200aob107.postini.com ([207.126.147.11]) with SMTP ID DSNKT4/hGBGA/3hbvgOfFR68kQvZmHoo95Hu@postini.com; Thu, 19 Apr 2012 09:55:50 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 50D691B7; Thu, 19 Apr 2012 09:55:30 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2990F21A5; Thu, 19 Apr 2012 09:55:30 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 3501224C07D; Thu, 19 Apr 2012 11:55:24 +0200 (CEST) Received: from steludxu4020.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 19 Apr 2012 11:55:29 +0200 From: Ulf Hansson To: , Chris Ball Cc: Daniel Drake , Per Forlin , Ulf Hansson , Johan Rudholm , Lee Jones Subject: [PATCH] mmc: core: Do not pre-claim host in suspend Date: Thu, 19 Apr 2012 11:55:25 +0200 Message-ID: <1334829325-3464-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.9 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkRzw8vm6+ZqHJi3V2+7RiC94lbFNDBN6ax3i1RAWa3jIlwhi5KJ0OTUbPDLaUhjtwVK6wM Since SDIO drivers may want to do some SDIO operations in their suspend callback functions, we must not keep the host claimed when calling them. Daniel Drake reported that libertas_sdio encountered a deadlock in it's suspend function. Signed-off-by: Ulf Hansson --- drivers/mmc/core/core.c | 55 +++++++++++++++++----------------------------- 1 files changed, 20 insertions(+), 35 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index e541efb..ba821fe 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2238,6 +2238,7 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable) mmc_card_is_removable(host)) return err; + mmc_claim_host(host); if (card && mmc_card_mmc(card) && (card->ext_csd.cache_size > 0)) { enable = !!enable; @@ -2255,6 +2256,7 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable) card->ext_csd.cache_ctrl = enable; } } + mmc_release_host(host); return err; } @@ -2272,49 +2274,32 @@ int mmc_suspend_host(struct mmc_host *host) cancel_delayed_work(&host->detect); mmc_flush_scheduled_work(); - if (mmc_try_claim_host(host)) { - err = mmc_cache_ctrl(host, 0); - mmc_release_host(host); - } else { - err = -EBUSY; - } + err = mmc_cache_ctrl(host, 0); if (err) goto out; mmc_bus_get(host); if (host->bus_ops && !host->bus_dead) { - /* - * 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); - } - mmc_release_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. (Calling - * bus_ops->remove() with a claimed host can - * deadlock.) - */ - 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; - } - } else { - err = -EBUSY; + if (err == -ENOSYS || !host->bus_ops->resume) { + /* + * We simply "remove" the card in this case. + * It will be redetected on resume. (Calling + * bus_ops->remove() with a claimed host can + * deadlock.) + */ + 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_bus_put(host);