From patchwork Tue May 9 08:27:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9717265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0C0460237 for ; Tue, 9 May 2017 08:27:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D16D526E78 for ; Tue, 9 May 2017 08:27:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6343282E8; Tue, 9 May 2017 08:27:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5077726E78 for ; Tue, 9 May 2017 08:27:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbdEII1o (ORCPT ); Tue, 9 May 2017 04:27:44 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:32804 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752024AbdEII1m (ORCPT ); Tue, 9 May 2017 04:27:42 -0400 Received: by mail-wr0-f178.google.com with SMTP id w50so63346618wrc.0 for ; Tue, 09 May 2017 01:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=430++NgDsfRLE2/2rRn0RsJBv5NaHP2iADbDyENosGQ=; b=KwiUJ/Fr4udKHe1ugvmXJXoLvyZUNYXUZoRjyq7bGbsJxufTSif+yZERUgWr0ZrXT5 3Zpm5ViqNAJOhFenxbwDKlO1D+37Uepfm4ZOUSrSFuAufSY/+OgDhIVoxiB2l1Pd2yJV j2G4hf0Vl9DrTk1fbha05xKcTT4Ud9QX9i0ag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=430++NgDsfRLE2/2rRn0RsJBv5NaHP2iADbDyENosGQ=; b=Fhwsoas6IkgGGzWATiwUkv9QzAxTWBeMbUwF01uBbkuXrW2lobL3SGzY2NLvq/lZyX 2WJ2mfbwFTYQSk+dI1idajM+Wl2Z2Pb8wuKOUBYkmE3sPg4vqahXcUWBIGgCzdguXZCl Z3Kjtngi2cwdwHr4I+RJAj8H3aU4q8ukNfUv3Y/7MO/Xb5sNlwc3RxJQ1a/8Epk8tlwx SOhgDaece+Gv1T5Pjgv6JcQViCGrOXK9jvQrcEt2zxRNw3DlooLItAvincHLr2Eoctph 1cHjHhmG+Lk92h84AQ/JZNBTjXxsvn8N2nCsh4BZu9L66DU6Q2Rqgo9evxqprEJyTE9m VTrg== X-Gm-Message-State: AODbwcCwgE5vs7kwRTgbEvT1Y2bJkxa0lvXPDP0JybHgHLNMlM5tBxdu FNv96a1z02G15/z8 X-Received: by 10.46.87.79 with SMTP id r15mr5762473ljd.4.1494318460682; Tue, 09 May 2017 01:27:40 -0700 (PDT) Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id o21sm3151108lfo.34.2017.05.09.01.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 01:27:40 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson Subject: [PATCH v3 4/5] mmc: dw_mmc: Prevent runtime PM suspend when SDIO IRQs are enabled Date: Tue, 9 May 2017 10:27:28 +0200 Message-Id: <1494318449-2591-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> References: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To be able to handle SDIO IRQs the dw_mmc device needs to be powered and providing clock to the SDIO card. Therefore, we must not allow the device to be runtime PM suspended while SDIO IRQs are enabled. To fix this, let's increase the runtime PM usage count while the mmc core enables SDIO IRQs. Later when the mmc core tells dw_mmc to disable SDIO IRQs, we drop the usage count to again allow runtime PM suspend. This now becomes the default behaviour for dw_mmc. In cases where SDIO IRQs can be re-routed as GPIO wake-ups during runtime PM suspend, one could potentially allow runtime PM suspend. However, that will have to be addressed as a separate change on top of this one. Signed-off-by: Ulf Hansson Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson --- Changes in v3: - Don't add include of pm_runtime.h as it's already there. --- drivers/mmc/host/dw_mmc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 635d76c..454b847 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1664,8 +1664,15 @@ static void __dw_mci_enable_sdio_irq(struct dw_mci_slot *slot, int enb) static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) { struct dw_mci_slot *slot = mmc_priv(mmc); + struct dw_mci *host = slot->host; __dw_mci_enable_sdio_irq(slot, enb); + + /* Avoid runtime suspending the device when SDIO IRQ is enabled */ + if (enb) + pm_runtime_get_noresume(host->dev); + else + pm_runtime_put_noidle(host->dev); } static void dw_mci_ack_sdio_irq(struct mmc_host *mmc)