From patchwork Tue Apr 11 22:55:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 9676201 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 0299260231 for ; Tue, 11 Apr 2017 22:56:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E330B2851F for ; Tue, 11 Apr 2017 22:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5B4E28589; Tue, 11 Apr 2017 22:56:41 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5113E2851F for ; Tue, 11 Apr 2017 22:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=t7BQ1hk3DdO4VqN6844KIBcKo3vVWESN9HkwAk8AFXQ=; b=pAK iFWdQ8x2lAwO+xPYWSLnhJcrD7mu7igIkoL80ZeIgoc+BpEavnoXEB2EIs1ZEU5O2FR8WZHU7ETIl 9FqaIgFICJgMZGpEZW+AD0nh4s6n60VulZw+KsS8IMjCgA41vlrM1s2vQDa67HJoqY7z/0nIXxctW 6hguU3xs57GuPdULzcneUvq0X8FaSUB0m4jf/BIC+R2+2y5TkBi5Z+rkefJOET8V6EXnFt/xSRwNx Onu74iONVEfOLrWez0v6Lm9aiS5ddDI5St35Yk/OaUH4HjUC9GvlK64ktsT3fT3XiH1NAXhv/wIfF mmY/XZppN9frJdfkcUB/Dw/Tp4WHN3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cy4iF-0007Lm-PK; Tue, 11 Apr 2017 22:56:39 +0000 Received: from mail-pg0-x235.google.com ([2607:f8b0:400e:c05::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cy4iC-0007JE-1A for linux-rockchip@lists.infradead.org; Tue, 11 Apr 2017 22:56:38 +0000 Received: by mail-pg0-x235.google.com with SMTP id 81so5231851pgh.2 for ; Tue, 11 Apr 2017 15:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=5kN1lK/LfevnXnyTtBN2c2ANaBwI19tKuZsbMv0n/ko=; b=XGNgscUWDK3BabBCa1apg6p/ljuacdxvKfvma8NaANRxf6Gcd3agcEdDao4wtYPsct IzH9UQ4ET9XY/8IsxStpcSe3OBFkiCK86lXbHO3n6MnR7SSzjnJCQmBFRbYweEQ8rHxD HXaqERg0fBuwOVXT2IyCDAiJRc5tpG33Xzvp8= 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; bh=5kN1lK/LfevnXnyTtBN2c2ANaBwI19tKuZsbMv0n/ko=; b=cEE8YN14zgSZ35+WBxIu9SC85iuuRVV5FnlpJbnNMXHLm6VOb9KIr9X5MQW6yxSGUp 1YWtqri04IBfLbvWxUSX8BqQ6xA5LUdPsW2ZprsqNlTRCGRXBUdJcwGq/CEZj0W/w+Ct fF9CaqagJOsrNnaIGKVW3k91Pc0fr/s0l3g0/l7MXtCWHF/Bn0ojoHiSNKcv1OEwON7v Pc6dICPfht5BnsA3jDUnrQ50G1wQQjCsIW2E27CPGDMyW1SqamNR0yr6CH1wojMyAfPm h82FERXZAIvVvnmB35TJyJ/SGt3pWoXMJU9yDU/X4qi5iZ29yCx/RC8YcPc+cQrbM/lC IiIw== X-Gm-Message-State: AN3rC/72rXP5CcLdckA0RlIBiHLrvCDSPPfR9HsQ3A7vkUg9ZFdKPgtuT8MY0XoVKoUus/Mw X-Received: by 10.84.216.91 with SMTP id f27mr11639318plj.130.1491951374354; Tue, 11 Apr 2017 15:56:14 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id 70sm12105135pfk.49.2017.04.11.15.56.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 15:56:13 -0700 (PDT) From: Douglas Anderson To: Jaehoon Chung , Ulf Hansson Subject: [PATCH] mmc: dw_mmc: Don't allow Runtime PM for SDIO cards Date: Tue, 11 Apr 2017 15:55:43 -0700 Message-Id: <20170411225543.987-1-dianders@chromium.org> X-Mailer: git-send-email 2.12.2.715.g7642488e1d-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170411_155636_107295_51685BD5 X-CRM114-Status: GOOD ( 16.79 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xzy.xu@rock-chips.com, Heiko Stuebner , Shawn Lin , briannorris@chromium.org, linux-mmc@vger.kernel.org, Douglas Anderson , stable@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, kevin@archlinuxarm.org, amstan@chromium.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP According to the SDIO standard interrupts are normally signalled in a very complicated way. They require the card clock to be running and require the controller to be paying close attention to the signals coming from the card. This simply can't happen with the clock stopped or with the controller in a low power mode. To that end, we'll disable runtime_pm when we detect that an SDIO card was inserted. This is much like with what we do with the special "SDMMC_CLKEN_LOW_PWR" bit that dw_mmc supports. NOTE: we specifically do this Runtime PM disabling at card init time rather than in the enable_sdio_irq() callback. This is _different_ than how SDHCI does it. Why do we do it differently? - Unlike SDHCI, dw_mmc uses the standard sdio_irq code in Linux (AKA dw_mmc doesn't set MMC_CAP2_SDIO_IRQ_NOTHREAD). - Because we use the standard sdio_irq code: - We see a constant stream of enable_sdio_irq(0) and enable_sdio_irq(1) calls. This is because the standard code disables interrupts while processing and re-enables them after. - While interrupts are disabled, there's technically a period where we could get runtime disabled while processing interrupts. - If we are runtime disabled while processing interrupts, we'll reset the controller at resume time (see dw_mci_runtime_resume), which seems like a terrible idea because we could possibly have another interrupt pending. To fix the above isues we'd want to put something in the standard sdio_irq code that makes sure to call pm_runtime get/put when interrupts are being actively being processed. That's possible to do, but it seems like a more complicated mechanism when we really just want the runtime pm disabled always for SDIO cards given that all the other bits needed to get Runtime PM vs. SDIO just aren't there. NOTE: at some point in time someone might come up with a fancy way to do SDIO interrupts and still allow (some) amount of runtime PM. Technically we could turn off the card clock if we used an alternate way of signaling SDIO interrupts (and out of band interrupt is one way to do this). We probably wouldn't actually want to fully runtime suspend in this case though--at least not with the current dw_mci_runtime_resume() which basically fully resets the controller at resume time. Fixes: e9ed8835e990 ("mmc: dw_mmc: add runtime PM callback") Cc: Reported-by: Brian Norris Signed-off-by: Douglas Anderson Acked-by: Jaehoon Chung Reviewed-by: Shawn Lin Tested-by: Brian Norris --- drivers/mmc/host/dw_mmc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 249ded65192e..e45129f48174 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -1620,10 +1621,16 @@ static void dw_mci_init_card(struct mmc_host *mmc, struct mmc_card *card) if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) { - set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); + if (!test_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags)) { + pm_runtime_get_noresume(mmc->parent); + set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); + } clk_en_a = clk_en_a_old & ~clken_low_pwr; } else { - clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); + if (test_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags)) { + pm_runtime_put_noidle(mmc->parent); + clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); + } clk_en_a = clk_en_a_old | clken_low_pwr; }