From patchwork Fri Sep 11 12:41:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 53466 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 7F97F22B26 for ; Fri, 11 Sep 2015 12:42:02 +0000 (UTC) Received: by wicgb1 with SMTP id gb1sf18096077wic.3 for ; Fri, 11 Sep 2015 05:42:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=aga/2LbPVCzW8vJbmC3AzgrLPSRu/X0GkudOv6Egnrc=; b=JHTB61ZFjKikX6Y5mdVdGoPR45itEfIFdvx8iXNdOq4T0M3DBVoZ8FPeWJp8X9Zn5z Ch90C1US81lAIEUhlj0mowogHepU/9eGJzO95jZQh9YhFYnDJkTx08TffQjn2NbZplQd 3Gv2wDHk8R9OhZW4pfreAfN+kT16Eqq75YltnKgTDaquQSu+CY4wTBmAxPF93w2RuKbq kQu2g1ZtivFb5pAX7SLo7GY6ql8hUSUDUSl12Uk8fuHY4Yn9aBd3HAGYxitt1/jT3BzN h6hlHwXk/Bz9QJa2B2rbKIph+Iw7vi8kNYkuwNnrez8xFiuK9/UCTrq9BRQNAMkNbku4 9aCQ== X-Gm-Message-State: ALoCoQmISsvp1A7ERisHyAAFWKHI4OqYcZ4OY2JsSzegq3qyG3QiCX30V8LgUpMq5ZtRqM8tj6kK X-Received: by 10.152.6.201 with SMTP id d9mr6321225laa.6.1441975321684; Fri, 11 Sep 2015 05:42:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.234 with SMTP id jf10ls344969lac.60.gmail; Fri, 11 Sep 2015 05:42:01 -0700 (PDT) X-Received: by 10.152.19.228 with SMTP id i4mr3698978lae.47.1441975321543; Fri, 11 Sep 2015 05:42:01 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id dp7si99167lbc.155.2015.09.11.05.42.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 05:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagj9 with SMTP id j9so47811050lag.2 for ; Fri, 11 Sep 2015 05:42:01 -0700 (PDT) X-Received: by 10.112.235.130 with SMTP id um2mr41703578lbc.72.1441975321442; Fri, 11 Sep 2015 05:42:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1568978lbq; Fri, 11 Sep 2015 05:42:00 -0700 (PDT) X-Received: by 10.152.25.225 with SMTP id f1mr33689456lag.52.1441975320821; Fri, 11 Sep 2015 05:42:00 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id n4si118865lbc.63.2015.09.11.05.42.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 05:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lamp12 with SMTP id p12so46335802lam.0 for ; Fri, 11 Sep 2015 05:42:00 -0700 (PDT) X-Received: by 10.152.21.37 with SMTP id s5mr37644695lae.118.1441975320434; Fri, 11 Sep 2015 05:42:00 -0700 (PDT) Received: from localhost.localdomain (c-83-233-167-104.cust.bredband2.com. [83.233.167.104]) by smtp.gmail.com with ESMTPSA id wg9sm32325lbb.6.2015.09.11.05.41.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 05:41:59 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Kishon Vijay Abraham I Subject: [PATCH] mmc: core: Keep host claimed while invoking mmc_power_off|up() Date: Fri, 11 Sep 2015 14:41:55 +0200 Message-Id: <1441975315-30387-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , As mmc_claim_host() invokes pm_runtime_get_sync() for the mmc host device, it's important that the host is kept claimed for *all* accesses to it via the host_ops callbacks. In some code paths for SDIO, particularly related to the PM support, mmc_power_off|up() is invoked without keeping the host claimed. Let's fix these. Moreover, mmc_start|stop_host() also invokes mmc_power_off|up() without claiming the host, let's fix these as well. Signed-off-by: Ulf Hansson Acked-by: Kishon Vijay Abraham I --- drivers/mmc/core/core.c | 6 ++++++ drivers/mmc/core/sdio.c | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 0520064..ed5f4ad 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2631,10 +2631,14 @@ void mmc_start_host(struct mmc_host *host) host->f_init = max(freqs[0], host->f_min); host->rescan_disable = 0; host->ios.power_mode = MMC_POWER_UNDEFINED; + + mmc_claim_host(host); if (host->caps2 & MMC_CAP2_NO_PRESCAN_POWERUP) mmc_power_off(host); else mmc_power_up(host, host->ocr_avail); + mmc_release_host(host); + mmc_gpiod_request_cd_irq(host); _mmc_detect_change(host, 0, false); } @@ -2672,7 +2676,9 @@ void mmc_stop_host(struct mmc_host *host) BUG_ON(host->card); + mmc_claim_host(host); mmc_power_off(host); + mmc_release_host(host); } int mmc_power_save_host(struct mmc_host *host) diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index b91abed..95bc101 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -897,11 +897,10 @@ static int mmc_sdio_pre_suspend(struct mmc_host *host) */ static int mmc_sdio_suspend(struct mmc_host *host) { - if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) { - mmc_claim_host(host); + mmc_claim_host(host); + + if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) sdio_disable_wide(host->card); - mmc_release_host(host); - } if (!mmc_card_keep_power(host)) { mmc_power_off(host); @@ -910,6 +909,8 @@ static int mmc_sdio_suspend(struct mmc_host *host) mmc_retune_needed(host); } + mmc_release_host(host); + return 0; } @@ -1018,15 +1019,24 @@ out: static int mmc_sdio_runtime_suspend(struct mmc_host *host) { /* No references to the card, cut the power to it. */ + mmc_claim_host(host); mmc_power_off(host); + mmc_release_host(host); + return 0; } static int mmc_sdio_runtime_resume(struct mmc_host *host) { + int ret; + /* Restore power and re-initialize. */ + mmc_claim_host(host); mmc_power_up(host, host->card->ocr); - return mmc_sdio_power_restore(host); + ret = mmc_sdio_power_restore(host); + mmc_release_host(host); + + return ret; } static int mmc_sdio_reset(struct mmc_host *host)